public function toKeyIndex($keyColumn = 'PrimaryKey')
    {
        $ret = [];
        $keyGetterMethod = 'get' . ucfirst($keyColumn);
        foreach ($this as $obj) {
            $ret[$obj->$keyGetterMethod()] = $obj;
        }

        return $ret;
    }
public function toKeyIndex($keyColumn = 'PrimaryKey')
    {
        $ret = [];
        $keyGetterMethod = 'get' . ucfirst($keyColumn);
        foreach ($this as $obj) {
            $ret[$obj->$keyGetterMethod()] = $obj;
        }

        return $ret;
    }
public function toKeyIndex ( $ keyColumn = 'PrimaryKey' ) { $ ret = [ ] ; $ keyGetterMethod = 'get' . ucfirst ( $ keyColumn ) ; foreach ( $ this as $ obj ) { $ ret [ $ obj -> $ keyGetterMethod ( ) ] = $ obj ; } return $ ret ; }
Get an associative array representation of the collection.
The first parameter specifies the column to be used for the key.

<code>
$res = $userCollection->toKeyIndex('Name');

$res = array(
'peter' => class User #1 {$name => 'peter', ...},
'hans' => class User #2 {$name => 'hans', ...},
...
)
</code>

@param string $keyColumn

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