我有下表
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()); 转储 向我显示所有字段,就好像我会选择 *
那么如何限制返回的字段以匹配我的选择呢?
提前致谢
马丁