CodeIgniter Forums
Database select a set value - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Database select a set value (/showthread.php?tid=33238)



Database select a set value - El Forum - 08-19-2010

[eluser]excitedcroc[/eluser]
Hi, couldnt find anything with the search about this so thought I'd ask...

Im trying to do a select like below to return all the fields of a table + a certain value (a_value) in this case.

Code:
$this->db->distinct();
$this->db->select( "p.*, 'a_value' as value" );
$this->db->from( "table p" );


Now this works in mysql but I think CI is escaping the quotes or something. I've tried \' but it still won't work!

Any ideas whats going wrong here ?

Many thanks..


Database select a set value - El Forum - 08-19-2010

[eluser]mddd[/eluser]
You are right, CI does escaping on the fields to prevent 'evil' stuff from coming in. You can tell it not to by adding 'false' as a second argument:
Code:
$this->db->select("p.*, 'a value' as value", false);