Sunday 15 January 2012

php - CodeIgniter Modifying results of a $query object then return that $query object -



php - CodeIgniter Modifying results of a $query object then return that $query object -

i need in model:

function getall() { $query = $this->db->get('mytable'); $results = $query->result(); // add together new property foreach ($results $result) $result->newproperty = compilelotsofstuff($result->column1, $result->column2, ...); // set in $query object $query = $result->recompile_into_query(); // homecoming query object, not results homecoming $query }

is possible? can't find on google , since tons of controllers utilize method everywhere, adding new property in controllers tremendous work , code repetition , cannot use

$this->select("*, 'value' `newproperty`");

in query need results calculate it

php mysql codeigniter activerecord

No comments:

Post a Comment