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