public function toKeyValue($keyColumn = 'PrimaryKey', $valueColumn = null)
    {
        $ret = array();
        $valueGetterMethod = (null === $valueColumn) ? '__toString' : ('get' . $valueColumn);

        if (!is_array($keyColumn)) {
            $keyColumn = array($keyColumn);
        }

        foreach ($this as $obj) {
            $ret[$this->getValueForColumns($obj, $keyColumn)] = $obj->$valueGetterMethod();
        }

        return $ret;
    }
public function toKeyValue($keyColumn = 'PrimaryKey', $valueColumn = null)
    {
        $ret = array();
        $valueGetterMethod = (null === $valueColumn) ? '__toString' : ('get' . $valueColumn);

        if (!is_array($keyColumn)) {
            $keyColumn = array($keyColumn);
        }

        foreach ($this as $obj) {
            $ret[$this->getValueForColumns($obj, $keyColumn)] = $obj->$valueGetterMethod();
        }

        return $ret;
    }
public function toKeyValue ( $ keyColumn = 'PrimaryKey' , $ valueColumn = null ) { $ ret = array ( ) ; $ valueGetterMethod = ( null === $ valueColumn ) ? '__toString' : ( 'get' . $ valueColumn ) ; if ( ! is_array ( $ keyColumn ) ) { $ keyColumn = array ( $ keyColumn ) ; } foreach ( $ this as $ obj ) { $ ret [ $ this -> getValueForColumns ( $ obj , $ keyColumn ) ] = $ 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 seconf for the value.

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

@param string|array $keyColumn   The name of the column, or a list of columns to call.
@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 seconf for the value .