Mysql codeigniter生成的更新中出现语法错误
我使用的是codeigniter,这里有一个sql查询。我知道问题出在哪里,但不知道如何编写适当的查询。 我犯了这样的错误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-
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')