我正在使用学说 2.1 为settings
表创建模型:
id | arg | value | category
1 | name | foo | general_settings
2 | desc | bar | general_settings
假设我有很多不同类别的设置。为了获得特定类别的所有设置,我执行以下操作:
$q = Doctrine_Query::create()
->from('Setting p')
->where('p.category = ?', $category_name);
此时一切正常。嗯.. 64,000 美元的问题是:是否存在允许我读取如下结果的数据访问替代方案?
$resultSet = $q->execute();
//the magic here could be use the -arg- column as index
$requested_setting = $resulSet['name']
//print the setting value
echo $requested_setting['value']; //should prints "foo"
//another way
echo $resulSet['desc']['value']; //should prints "bar"