我正在使用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中的正确查询是什么?
答案 0 :(得分:3)
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 `fx_tasks`
SET `timer_status` = 'On',
`start_time` = 1444629730,
`timer_started_by` = '46'
WHERE `t_id` = '3438'
答案 1 :(得分:1)
Exception in thread "main" org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException
打印时间戳
date_default_timezone_set('asia/kolkata') $user = $this->user; $data = array( 'timer_status' => $action, 'start_time' => date('H:i:s'), 'timer_started_by' => $user ); $this->db->where('t_id', $task); $this->db->update('fx_tasks', $data);
返回当前时间并提供时区。如果您需要使用date('H:i:s')