Test:
tableName: test
columns:
test_id:
name: test_id as id
primary: true
autoincrement: true
type: integer
notnull: true
test_name:
name: test_name as name
type: string(255)
test_title:
name: test_title as title
type: string(255)
这DQL声明
$dql = Doctrine_Query::create()->select('t.name')->from('Model_Test t');
以下SQL IST产生
SELECT t.test_id AS t__test_id, t.test_name AS t__test_name FROM test t
但毕竟有在原则中获取结果,即使没有选择,我也可以访问标题字段:
foreach ($results as $result) {
foreach ($result as $filed => $value) {
echo "$filed => $value <hr>"; // echoes 'title' => null but title in db has other value
}
}
也通过Zend_Debug :: dump($ results-> toArray())转储;显示我所有的领域,如果我会做一个选择*
那么如何限制返回的字段以匹配我的选择?
在此先感谢
马丁
你有没有发现这种情况的解决方案?我也在努力。我不想将不必要的垃圾作为json传递给ajax消费者。 – 2012-04-01 11:18:20
Nevermind, - > setHydrationMode(Doctrine :: HYDRATE_ARRAY)已解决它。 – 2012-04-01 11:29:05