Yii2 strtoupper()要求参数1为字符串,数组给定
我得到这个错误,我已经重新阅读我的代码多次。有什么问题Yii2 strtoupper()要求参数1为字符串,数组给定,yii2,Yii2,我得到这个错误,我已经重新阅读我的代码多次。有什么问题 $query->select(['User.name', 'Student.student_ID', 'Student.group_ID']) ->from('User') ->innerJoin('Student', '`Student`.`user_ID` = `User`.`user_ID`') ->leftJoin('Group', '`
$query->select(['User.name', 'Student.student_ID', 'Student.group_ID'])
->from('User')
->innerJoin('Student', '`Student`.`user_ID` = `User`.`user_ID`')
->leftJoin('Group', '`Group`.`group_ID` = `Student`.`group_ID`')
->where(['Student.batch_ID' => $batchid, 'Student.group_ID' =>null, ['!=', 'Student.user_ID', Yii::$app->user->identity->user_ID]])
->orWhere(['Student.batch_ID' => $batchid, ['!=', 'Student.group_ID', null], ['!=', 'Student.user_ID', Yii::$app->user->identity->user_ID], ['!=', 'Group.approval_ID', 2]])
->orderBy(['User.name' => SORT_ASC]);
$studentarray = $query->all(); <- strtoupper() invoked here?
$query->select(['User.name','Student.Student\u ID','Student.group\u ID'])
->来自('用户')
->innerJoin('Student','Student`.'user\u ID`='user`.'user\u ID`)
->leftJoin('Group','Group`.'Group\u ID`='Student`.'Group\u ID`)
->其中(['Student.batch\u ID'=>$batchid',Student.group\u ID'=>null,['!=','Student.user\u ID',Yii::$app->user->identity->user\u ID]]
->或其中(['Student.batch\u ID'=>$batchid,['!=','Student.group\u ID',null],“!=”,'Student.user\u ID',Yii::$app->user->identity->user\u ID],“!=”,'group.approval\u ID',2])
->orderBy(['User.name'=>SORT_ASC]);
$studentarray=$query->all() 试试这个:
$query->select(['User.name', 'Student.student_ID', 'Student.group_ID'])
->from('User')
->innerJoin('Student', '`Student`.`user_ID` = `User`.`user_ID`')
->leftJoin('Group', '`Group`.`group_ID` = `Student`.`group_ID`')
->where(['Student.batch_ID' => $batchid])
->andWhere(['!=', 'Student.user_ID', Yii::$app->user->identity->user_ID])
->andWhere(['Student.group_ID' => null])
->orWhere(['==', 'Group.approval_ID', 2]])
->orderBy(['User.name' => SORT_ASC]);
请查看正确的where()
语法。还没有测试出来,但这应该是查询的正确格式。请显示调用strtoupper()的代码。不仅是选择…嗨。谢谢你的答复。我已经编辑了我的代码。不确定这是否是你想要的@斯盖西:我没看见那个骗子。功能。请显示使用此函数的代码。erm。很抱歉我没有使用strotupper()。当我使用$studentarray=$query->all()时,某个Yii2函数调用Strtoupper();你在哪里使用$studentarray?在GridView?嗨。我已经阅读了文件,这就是我如何提出上述代码。错误现在消失了,但是我的$studentarray中没有任何内容。让我试着张贴我的要求条件,你能检查你的代码是否能满足这些条件。非常感谢。