Select specific fields from MySQL table based on variable in PHP/CodeIgniter -


just wondering how best achieve following in codeigniter active record:

$language = 'nl'; // or 'en', 'sp', etc. $this->db->select('id, description_'.$language.' description, some_more_fields'); $q = $this->db->get('table_name'); 

if use $q won't proper database result object , i'll fatal errors later when using it:

php fatal error: call member function num_rows() on non-object in /somescript.php on line 12345 

also, $language variable derived user-input, should imo escaped..

thank you!

you're quoting wrong,

$this->db->select('id, description_'.$language.' description, some_more_fields'); 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -