SQLSTATE[HY093]: 参数编号无效:Columns/Parameters 是基于 1 的 - yii2
SQLSTATE[HY093]: Invalid parameter number: Columns/Parameters are 1-based - yii2
我正在尝试在多个列中执行 filter/search。我被这个错误困住了:
SQLSTATE[HY093]: Invalid parameter number: Columns/Parameters are 1-based
知道这是什么吗?
下面的代码是我的搜索模型。
我的代码:
$combo = explode('.',$this->storeNamesCombo);
$storeClasses = ArrayHelper::map(StoreClasses::find()->all(), 'id', 'name');
$storeFamilies = ArrayHelper::map(StoreFamilies::find()->all(), 'id', 'name');
$storePlatforms = ArrayHelper::map(StorePlatforms::find()->all(), 'id', 'name');
$mc_search = [];
$mf_search = [];
$mp_search = [];
foreach($combo as $item){
$temp_mc = array_search($item, $storeClasses);
if($temp_mc !== False){ $mc_search[] = $temp_mc; }
$temp_mf = array_search($item, $storeFamilies);
if($temp_mf !== False){ $mf_search[] = $temp_mf; }
$temp_mp = array_search($item, $storePlatforms);
if($temp_mp !== False){ $mp_search[] = $temp_mf; }
}
if(!empty($mc_search)){
foreach($mc_search as $item){
$query->andFilterWhere(['or', '"storeNames"."classId"' => $item]);
}
}
if(!empty($mf_search)){
foreach($mf_search as $item){
$query->andFilterWhere(['or', '"storeNames"."familyId"' => $item]);
}
}
if(!empty($mp_search)){
foreach($mp_search as $item){
$query->andFilterWhere(['or', '"storeNames"."platformId"' => $item]);
}
}
if(!empty($combo)){
foreach($combo as $item){
$query->where(['ilike', '"storeNames"."subFamilyName"', $item],
['ilike', '"storeNames"."variantName"', $item]);
}
}
将您的上一条语句更改为:
if(!empty($combo)){
foreach($combo as $item){
$query->andWhere([
'or',
['ilike', '"storeNames"."subFamilyName"', $item],
['ilike', '"storeNames"."variantName"', $item]
]);
}
}
我正在尝试在多个列中执行 filter/search。我被这个错误困住了:
SQLSTATE[HY093]: Invalid parameter number: Columns/Parameters are 1-based
知道这是什么吗? 下面的代码是我的搜索模型。
我的代码:
$combo = explode('.',$this->storeNamesCombo);
$storeClasses = ArrayHelper::map(StoreClasses::find()->all(), 'id', 'name');
$storeFamilies = ArrayHelper::map(StoreFamilies::find()->all(), 'id', 'name');
$storePlatforms = ArrayHelper::map(StorePlatforms::find()->all(), 'id', 'name');
$mc_search = [];
$mf_search = [];
$mp_search = [];
foreach($combo as $item){
$temp_mc = array_search($item, $storeClasses);
if($temp_mc !== False){ $mc_search[] = $temp_mc; }
$temp_mf = array_search($item, $storeFamilies);
if($temp_mf !== False){ $mf_search[] = $temp_mf; }
$temp_mp = array_search($item, $storePlatforms);
if($temp_mp !== False){ $mp_search[] = $temp_mf; }
}
if(!empty($mc_search)){
foreach($mc_search as $item){
$query->andFilterWhere(['or', '"storeNames"."classId"' => $item]);
}
}
if(!empty($mf_search)){
foreach($mf_search as $item){
$query->andFilterWhere(['or', '"storeNames"."familyId"' => $item]);
}
}
if(!empty($mp_search)){
foreach($mp_search as $item){
$query->andFilterWhere(['or', '"storeNames"."platformId"' => $item]);
}
}
if(!empty($combo)){
foreach($combo as $item){
$query->where(['ilike', '"storeNames"."subFamilyName"', $item],
['ilike', '"storeNames"."variantName"', $item]);
}
}
将您的上一条语句更改为:
if(!empty($combo)){
foreach($combo as $item){
$query->andWhere([
'or',
['ilike', '"storeNames"."subFamilyName"', $item],
['ilike', '"storeNames"."variantName"', $item]
]);
}
}