0
我是CRON任务的新成员,所以我在练习它;对于初学者,我想提出一个cron作业将使用CodeIgniter和PHP用户, 这里是我的模型:CodeIgniter任务调度程序将任务调度到任务调度程序
<?php
class Cron_Model extends CI_Model{
public function adduser($firstname,$lastname){
$data = array(
'firstname' => $firstname,
'lastname' => $lastname
);
$query = $this->db->insert('user_account',$data);
return $query;
}
}
和:这是我的控制器:
<?php
class Cron_Controller extends CI_Controller{
public function __construct(){
parent::__construct();
$this->load->database();
$this->load->model('Cron_Model');
// this controller can only be called from the command line
if (!$this->input->is_cli_request()) show_error('Direct access is not allowed');
}
public function AddAUser(){
$fname = "JUNCEL";
$lname = "CARREON";
$this->Cron_Model->adduser($fname,$lname);
}
}
?>
我将它添加到数据库,尽管名字和姓氏是相同的,但没关系,这只是一项试验工作。
所以,现在我想调用函数AddAUser()的任务调度,
我已经试过这件事情:然后在添加参数浏览它的任务计划
C:\xampp\htdocs\post\application\controllers\cron_controller.php
(可选):我把AddAUser,所以基本上变成这个样子:
C:\xampp\htdocs\post\application\controllers\cron_controller.php AddAUser
然后我试着运行它,但我还没有看到在数据库中的东西!发生什么事?
Codeigniter是一个旧框架! ,请使用新的框架像Yii'','Phalconphp','laravel'或者其他微型框架的小项目 –
哦!我将在我们的论文之后练习laravel,但是这个东西并没有工作,我想问的是我会在任务调度程序中放入什么东西!什么网址 – GGsThePlayDude
请把你的错误代码在这里检查它!这段代码在我所有的项目中工作良好,删除'if(!$ this-> input-> is_cli_request())'并在浏览器中测试它 –