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

About the results

ex: $phql = "SELECT c.* FROM Cars AS c ORDER BY c.name"; $cars = $manager->executeQuery($phql);

if i want a value, i have to write
"foreach ($cars as $car) { echo "Name: ", $car->name, "\n"; };" so i want to get a array? i just write "var_dump($cars);"

how to do it?



85.5k
edited Oct '15

i am not 100% sure, but I think it returns a model instance.

can you try

print_r($cars->toArray());

Sorry if i am wrong, i dont use the model manager to create custom queries



9.6k

原生phql 查询返回的是对象形式,我想直接取得的结果是数组形式,该怎么写?

edited Oct '15

You can use ->toArray() on both the QueryInterface returned by executeQuery and the iterated row ModelInterfaces.

var_dump($cars->toArray());
foreach($cars as $car) {
    var_dump($car->toArray());
}