CodeIgniter Forums
Worked in 1.5 but gives error in 1.7.1 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Worked in 1.5 but gives error in 1.7.1 (/thread-17919.html)



Worked in 1.5 but gives error in 1.7.1 - El Forum - 04-20-2009

[eluser]citryer[/eluser]
Following used to work in 1.5.x

Code:
//my_model.php
$this->db->select("id, DATE_FORMAT(postdt,'%D %M %Y') as newsdt, title");
$this->db->where('id',$id); // Confirmed value received
$query = $this->db->get('my_news_table');
return $query->row();

Since the upgrade to 1.7.x This now produces following error:
Code:
Fatal error: Call to a member function row() on a non-object in G:\wamp\XXX\YYY\models\my_model.php on line 48

Query by the way works when I remove the Date_Format portion from the select clause.


Worked in 1.5 but gives error in 1.7.1 - El Forum - 04-20-2009

[eluser]rogierb[/eluser]
try
Code:
$this->db->select("id, DATE_FORMAT(postdt,'%D %M %Y') as newsdt, title", FALSE);

Because it is probably due to backticks the query doesn't work.


Worked in 1.5 but gives error in 1.7.1 - El Forum - 04-20-2009

[eluser]citryer[/eluser]
You are absolutely correct...

Looked closely at the docs after your comments.

Quote:$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.

appreciate your help.

Thanks.