如何使用codeigniter
在cpanel中运行cron<?php
class Cron extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('email_model');
}
public function index()
{
$c_date = date('Y-m-d');
$remider_data = $this->email_model->get_customer_remider_data(array('status'=>'1', 'reminder_date_before' => $c_date));
foreach($remider_data as $remider_data_mail)
{
$mailTo = $remider_data_mail->reminder_email;
$nameTo = $remider_data_mail->reminder_email;
$mailFrom ="test@gmail.com";
$nameFrom = "project Board";
$subject ="reminder_date_before";
$body = $remider_data_mail->reminder_description;
$headers = "Content-type: text/html;\n";
$headers .= "From: ". $nameFrom . " <" . $mailFrom . ">\n";
$headers .= "Reply-To: ". 'no-reply@gmail.com' . " <" . 'Project Board' . ">\n";
$headers .= "Return-Path: " . $mailFrom ."\n";
if(mail($mailTo, $subject, $body, $headers))
{
echo 'email sent';
}
}
}
}
这是我的控制器 - &gt; Cron文件。
我正在使用索引功能来使用Cron作业。
我在cpanel / usr / bin / php /home/*****/public_html/*****/index.php cron index
中设置我也使用php /full-path-to-cron-file/cron.php / test / index
答案 0 :(得分:0)
您可以使用以下命令从命令行调用codeigniter:
SELECT * FROM aktionen WHERE
jahr LIKE '$filter_jahr' AND
kunde LIKE '$filter_kunde' AND
kampagne LIKE '$filter_kampagne' AND
(objekt1 LIKE '$filter_objekt' OR
objekt2 LIKE '$filter_objekt' OR
objekt3 LIKE '$filter_objekt' OR
objekt4 LIKE '$filter_objekt') AND
mediamix LIKE '$filter_mediamix' AND
kosten LIKE '$filter_kosten' AND
schulnote LIKE '$filter_schulnote' AND
feedback_status LIKE '$filter_feedback'
ORDER BY kunde ASC, aktionsname ASC
参考此处:https://www.codeigniter.com/userguide3/general/cli.html
答案 1 :(得分:0)
我不知道为什么,
php /path/to/the/project/index.php控制器功能
对我不起作用,但这对我有用
php /path/to/the/project/index.php控制器/功能
注意控制器和功能之间的“/”。
答案 2 :(得分:0)
我的服务器上有一些定时任务。我只是这样称呼那个控件: PHP代码:
/usr/bin/php /var/www/html/yourwebsite/index.php controllername functionname