在学说中使用列值作为数组索引
2022-08-30 17:59:40
我正在使用学说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"