如何使用doctrine 2从查询中获取列名?

时间:2014-07-07 14:36:18

标签: php mysql doctrine

我需要在doctrine 2执行的sql查询中获取列的名称。

这在我的学说1.2中起作用了

public function executeQuery($query, $conn) {

    /*.......*/

    $result = $conn->execute($query);

    $array_result = array();
    $long = $result->columnCount();

    while ($long > $iterator) {
        $meta = $result->getColumnMeta($iterator);
        $array_result[$iterator]['name'] = $meta['name'];
        $array_result[$iterator]['type'] = $meta['native_type'];
        $iterator++;
    }
    return $array_result;
}

我现在正在使用symfony 2和doctrine 2.我需要在SELECT子句中获取名称和数据类型字段。例如:

SELECT name, lastname FROM profile

我需要使用doctrine从php获取名称和姓氏字段。

0 个答案:

没有答案