Welcome Guest, Not a member yet? Register   Sign In
Efficiently getting a one-dimensional array of results using ActiveRecord
#1

[eluser]bientek[/eluser]
In my CI Models, I find myself frequently selecting a single column and then moving data from the object array into a one-diemsional array with a for-loop, like this:
Code:
$this->db->select('id');
$this->db->from('MyTable');
$rows = $this->db->get()->result();
$ids = array();
foreach ($row as $r)
$ids[] = $r->id;

Is there a better way?


Messages In This Thread
Efficiently getting a one-dimensional array of results using ActiveRecord - by El Forum - 07-05-2012, 11:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB