未定义的索引:cakephp中的usertypename

时间:2016-04-12 10:29:59

标签: cakephp cakephp-2.0 cakephp-2.3 cakephp-2.1

控制器部件代码

$Viewcustomer=$this->Viewcustomer->query("SELECT GROUP_CONCAT(usertype_name SEPARATOR ',') as usertypename, customer_name FROM `pre`.`customer` AS `Viewcustomer` WHERE `Viewcustomer`.`customer_status` = 0 AND `Viewcustomer`.`customer_type` = 'B1'  
GROUP BY `customer_id`  DESC"); 
$this->set("Viewcustomer",$Viewcustomer);

查看零件代码

 foreach($Viewcustomer as $customers){
  echo  $customers['Viewcustomer']['usertypename'];
    }

1 个答案:

答案 0 :(得分:0)

usertypename不应该进入$customers['Viewcustomer']['usertypename'];
这应该是$customers['0']['usertypename'];
请打印您的阵列并分享您的代码