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.

Robots::find()->toArray(array("column1")); not working

Hi,

I used phalcon version 1.3 and moved to version 2.0.10.

In version 1.3

Robots::find()->toArray(array("column1"));

Used to set the results in an array and only with the column named "column1"

But in version 2.0.10 this is not the case.

Has the documentation changed, is there an new function to filter the toArray with specific columns? Or is this an bug?

edited Apr '16

Robots::find(array("columns" => "column1"))->toArray();

Try that, haven't tested it because I'm mobile.



629

Well thank you for your time

The above code was only to explain my problem in simple code.

But i actually work with relations so it becomes like this:

$robot = Robots::findFirst(2);
$robot->robotsParts->toArray(array("column1"));

In this case there is no findFirst() where you can put filters. It probably works but thats not the solution for my case

You could do this:

$robot->getRobotsParts(array("columns" => "column1"));

Could you post the model class and the output of toArray()?



629
Accepted
answer
edited Apr '16

This works thanks!

You and Aaron are both amazing!

I appreciate all the help :)

Still do not understand why in the documentation it says toArray([$array]);

But now i can continue thanks

EDIT: I ment to accept your answer xD Can't edit that.. sorry

You could do this:

$robot->getRobotsParts(array("columns" => "column1"));

Could you post the model class and the output of toArray()?