We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to store data obtained from db using find() method in multi-dimensional array.

I obtained some data from db using find() method... the data contains 2 rows named "controllers " and "actions" ....now i want to pass this data in a 2-D array....i got stuck in the loop itself How to do it??? Please help!!!!

$check = AccessRole::find("role_id=1");
$count = count($check); // for my data....numbers rows obtained is 57
$resources = array(); // 2-d Array where i want to pass the data...

for ($i = 0; $i < $count; $i++) {

}

@jaikumar002 Could you please explain a bit more.



43.9k
Accepted
answer
edited Dec '16

hi,

isn't toArray() what you are looking for ?

$resource = $check->toArray();

see https://docs.phalcon.io/en/latest/api/Phalcon_Mvc_Model.html method toArray()

Also, https://docs.phalcon.io/en/latest/reference/models-advanced.html#hydration-modes could do the trick



43.9k

phalcon is really good ;-))