symfony 2 doctrine $query->getArrayResult() how to remove selected key->values from result

StackOverflow https://stackoverflow.com/questions/18346960

質問

As I don't want id values from a select with createQuery, but the select command doesn't allow omitting id (primary key) from the actual query (using "partial") I need to remove the id's from the result from getArrayResult()

正しい解決策はありません

他のヒント

I made this small recursive key remover static class:

class arrayTool
{
public static function cleanup($array, $deleteKeys)
{
    foreach($array as $key => $value )
    {
        if(is_array( $value))
        {
            $array[$key] = self::cleanup($array[$key], $deleteKeys);
        } else {
            if (in_array($key, $deleteKeys)) unset($array[$key]);
        }
    }
    return $array;
}
}

Which is called by an array containing one or more keys to be removed from the result, of any array depth:

$array = arrayTool::cleanup($array, array('id', 'id2'));
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top