|
PHP复制代码
/*用于提问时候分类的选择*/
function get_js (){
$categoryjs=$category1=$category2=$category3='';
$query="SELECT * FROM `ask_category` order by displayorder asc ";
while($category=$this->db->query($query)){
switch($category['grade']){ //这行报错
case 1:
$category1.='["'.$category['id'].'","'.$category['name'].'"],';
break;
case 2:
$category2.='["'.$category['pid'].'","'.$category['id'].'","'.$category['name'].'"],';
break;
case 3:
$category3.='["'.$category['pid'].'","'.$category['id'].'","'.$category['name'].'"],';
break;
}
}
$category1=substr($category1,0,-1);
$category2=substr($category2,0,-1);
$category3=substr($category3,0,-1);
$categoryjs="{\"category1\":[$category1],\"category2\":[$category2],\"category3\":[$category3]}";
return $categoryjs;
}
复制代码
报错信息
Fatal error: Cannot use object of type CI_DB_mysql_result as array in C:\xampp\htdocs\input_public\system\application\models\input_model.php on line 17
就在switch那行.....
为什么??ci里不能这么用?谢谢 |
|