Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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.



30.7k
Accepted
answer
edited Dec '16

hi,

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

$resource = $check->toArray();

see https://docs.phalconphp.com/en/latest/api/Phalcon_Mvc_Model.html method toArray()

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



30.7k

phalcon is really good ;-))