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 find the result set in one attribute

I want to achieve a similar effect as follows:

    $findResult = array(
        0 => array(
        'id' => 1,
        'name' => 'vendor',
        'sex' => 1
        1 => array(
        'id' => 1,
        'name' => 'vendor',
        'sex' => 1

Such as this is the result of find back. I think in this result always add in one unit Like this: $findResult[0]['age'] = 18; $findResult[1]['age'] = 20;

Because the find the returned result set is a one-to-one correspondence table field, and I want to add this attribute is not secondary personal name of paragraph, so I can't increase, do you have any other methods.


Change the hydration mode:

$robots = Robots::find();

//Return every robot as an array

foreach ($robots as $robot) {
    echo $robot['year'], PHP_EOL;


Why I did not respond to a click on the Reply -- can't Reply you!