coders. I’m running a little problem here and can’t find the solution. I’m building a query using Active Record from CI. This is the code for the query:
$this->db->select("u.id AS user_id, u.email, p.display_name, p.first_name, p.last_name, s.status_id, s.message");
$this->db->select("DATE_FORMAT(s.created_at, `Publicado el %d/%m/%Y a las %h:%i %p`) AS created_at", FALSE);
$this->db->join($this->_table_users . ' u', 'u.id = s.user_id');
$this->db->join($this->_table_profiles . ' p', 'p.user_id = u.id');
$this->db->where_in('user_id', $str);
$this->db->where('deleted', 0);
$this->db->from($this->_table . ' s');
$this->db->order_by('s.created_at', 'desc');
But I’m getting this error:
Error Number: 1054
Unknown column ‘Publicado el %d/%m/%Y a las %h:%i %p’ in ‘field list’
SELECT
u.idAS user_id,u.p.display_name,p.first_name,
p.last_name,s.status_id,s.message, DATE_FORMAT(s.created_at,Publicado el > %d/%m/%Y a las %h:%i %p) AS created_at FROM (default_statuss,default_status) JOIN >default_usersu ONu.id=default_s.user_idJOINdefault_profilesp ON
p.user_id=u.idWHEREuser_idIN (‘5726, 2, 10293’) ANDdeleted= 0 ORDER
BYs.created_atdesc LIMIT 2
Does any know where I can use DATE_FORMAT within this query? The funny is the same query write as pure SQL works
Cheers and thanks in advance
Add FALSE as the second parameter in your SELECT statement. You may have to do something similar in your WHERE clause as well.
Some links to look over:
http://ellislab.com/forums/viewthread/74206/#368778
http://ellislab.com/forums/viewthread/206962/#963061
http://ellislab.com/codeigniter/user-guide/helpers/date_helper.html