Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql codeigniter生成的更新中出现语法错误_Mysql_Sql_Codeigniter_Sql Update_Syntax Error - Fatal编程技术网

Mysql codeigniter生成的更新中出现语法错误

Mysql codeigniter生成的更新中出现语法错误,mysql,sql,codeigniter,sql-update,syntax-error,Mysql,Sql,Codeigniter,Sql Update,Syntax Error,我使用的是codeigniter,这里有一个sql查询。我知道问题出在哪里,但不知道如何编写适当的查询。 我犯了这样的错误 UPDATE `fx_tasks` SET `timer_status` = 'On', `start_time` = 1444629730, `timer_started_by` = '46' WHERE `t_id` = '3438' ORDER BY `timer_status=On` DESC 我的codeingiter查询如下: $this->db-

我使用的是codeigniter,这里有一个sql查询。我知道问题出在哪里,但不知道如何编写适当的查询。 我犯了这样的错误

UPDATE `fx_tasks` 
SET `timer_status` = 'On', `start_time` = 1444629730, `timer_started_by` = '46' 
WHERE `t_id` = '3438' 
ORDER BY `timer_status=On` DESC
我的codeingiter查询如下:

$this->db->set('timer_status', $action);
$this->db->set('start_time', time());
$this->db->set('timer_started_by', $this -> user);
$this->db->order_by("timer_status=On","DESC");
$this->db->where('t_id',$task)->update($this->tasks_table);

codeigniter中的正确查询是什么?

update语句没有
order by
子句。将其从codeigniter代码中删除:

$this->db->set('timer_status', $action);
$this->db->set('start_time', time());
$this->db->set('timer_started_by', $this -> user);
$this->db->where('t_id',$task)->update($this->tasks_table);
// order by removed
您应该得到一个有效的update语句:

UPDATE `fx_tasks` 
SET    `timer_status` = 'On',
       `start_time` = 1444629730,
       `timer_started_by` = '46'
WHERE  `t_id` = '3438'

update
语句没有
orderby
子句。将其从codeigniter代码中删除:

$this->db->set('timer_status', $action);
$this->db->set('start_time', time());
$this->db->set('timer_started_by', $this -> user);
$this->db->where('t_id',$task)->update($this->tasks_table);
// order by removed
您应该得到一个有效的update语句:

UPDATE `fx_tasks` 
SET    `timer_status` = 'On',
       `start_time` = 1444629730,
       `timer_started_by` = '46'
WHERE  `t_id` = '3438'
使用

date('H:i:s')
返回当前时间并提供时区。如果需要打印时间戳,请使用
date('Y-m-dh:i:s')

使用

date('H:i:s')
返回当前时间并提供时区。如果需要打印时间戳,请使用
date('Y-m-dh:i:s')