public function toKeyValue($keyColumn = 'PrimaryKey', $valueColumn = null)
    {
        $ret = [];
        $keyGetterMethod = 'get' . $keyColumn;
        $valueGetterMethod = (null === $valueColumn) ? '__toString' : ('get' . $valueColumn);
        foreach ($this as $obj) {
            $ret[$obj->$keyGetterMethod()] = $obj->$valueGetterMethod();
        }

        return $ret;
    }
public function toKeyValue($keyColumn = 'PrimaryKey', $valueColumn = null)
    {
        $ret = [];
        $keyGetterMethod = 'get' . $keyColumn;
        $valueGetterMethod = (null === $valueColumn) ? '__toString' : ('get' . $valueColumn);
        foreach ($this as $obj) {
            $ret[$obj->$keyGetterMethod()] = $obj->$valueGetterMethod();
        }

        return $ret;
    }
public function toKeyValue ( $ keyColumn = 'PrimaryKey' , $ valueColumn = null ) { $ ret = [ ] ; $ keyGetterMethod = 'get' . $ keyColumn ; $ valueGetterMethod = ( null === $ valueColumn ) ? '__toString' : ( 'get' . $ valueColumn ) ; foreach ( $ this as $ obj ) { $ ret [ $ obj -> $ keyGetterMethod ( ) ] = $ obj -> $ valueGetterMethod ( ) ; } return $ ret ; }
Get an associative array representation of the collection
The first parameter specifies the column to be used for the key,
And the second for the value.

<code>
$res = $coll->toKeyValue('Id', 'Name');
</code>

@param string $keyColumn
@param string $valueColumn

@return array
Get an associative array representation of the collection The first parameter specifies the column to be used for the key And the second for the value .