我无法在cakephp中获取有限的字段。
以下是查询查询:
$payment = $this -> Payment -> find('first', array('recursive' => 2));
在调试时,我得到以下输出。
[Pricing] => Array
(
[id] => 5
[plan_id] => 1
[price] => 150
[Plan] => Array
(
[id] => 1
[course] => One
[course_name] => OnePlus
[description] => Lorem Ipsum is simply dummy text
[discount] => 0
)
)
但是从Plan
数组我只需要course_name
。所以我试过了:
$payment = $this -> Payment -> find('first', array('recursive' => 2,
'fields' => array(
'Pricing.Plan.course_name'
)
));
但我收到错误:Column not found: 1054 Unknown column 'Pricing.Plan.course_name' in 'field list'
请帮助我从couse_name
数组中获取Plan
字段。
答案 0 :(得分:0)
<强>尝试:强>
$payment = $this -> Payment -> find('first', array('recursive' => 2,
'fields' => array(
'Plan.course_name'
)
));
答案 1 :(得分:0)
试试这个
$payment = $this->Payment->find('first', array('recursive' => 2,
'fields' => array(
'Pricing.*','Plan.course_name'
)
));