Monday, June 20, 2011

Codeigniter: SQL Select query FROM_UNIXTIME

I keep having error when I made this sql select:
$this->db->select("FROM_UNIXTIME( LOGTIME, '%D %M %Y') AS date");

And how to fix it, is by adding FALSE on db select like example below:
$this->db->select("FROM_UNIXTIME( LOGTIME, '%D %M %Y') AS date", FALSE);

3 comments:

  1. Hi am using below line in my query
    $this->db->group_by('FROM_UNIXTIME(E.servertime,"%Y-%m-%d")', FALSE);
    but when i execute its appending FROM_UNIXTIME(E.servertime, `"%Y-%m-%d")` how to resolve this please help me

    ReplyDelete
    Replies
    1. $this->db->select() accepts an optional second parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks. This is useful if you need a compound select statement.

      Delete
  2. $this->db->select() accepts an optional second parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks. This is useful if you need a compound select statement.

    ReplyDelete