Cannot use isset() on the result of an expression (you can use "null !== expression" instead)
5a7f4621a84ba: GET http://dfw.loc/admin/product?ProductSearch%5Bid%5D=&ProductSearch%5Btitle%5D=&ProductSearch%5Bcategory_id%5D=1&ProductSearch%5Bdesigner_id%5D=&ProductSearch%5Bart%5D=&ProductSearch%5Bnew%5D=&ProductSearch%5Bhit%5D=&ProductSearch%5Bsale%5D= at 2018-02-10 07:21:05 pm by 127.0.0.1
ProductSearch [
'id' => ''
'title' => ''
'category_id' => '1'
'designer_id' => ''
'art' => ''
'new' => ''
'hit' => ''
'sale' => ''
]
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'category_id' in where clause is ambiguous
The SQL being executed was: SELECT COUNT(*) FROM `product` `p` LEFT JOIN `product` `pp` ON `p`.`id` = `pp`.`category_id` WHERE (`p`.`category_id`='1') AND (`category_id` IN ('6', '7', '8'))
public function search($params)
{
$query = Product::find()
->from(['p' => Product::tableName()])
->with(['designer', 'category'])
->joinWith([
'childrenProducts pp' => function (ActiveQuery $query) {
if (!empty($this->category_id)) {
$ids = [$this->category_id];
$childrenIds = $ids;
while ($childrenIds = Category::find()
->alias('p2')
->select('id')
->andWhere(['parent_id' => $childrenIds])
->column()) {
$ids = array_merge($ids, $childrenIds);
}
$query->andWhere(['category_id' => array_unique($ids)]);
}
}
]);
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
$query->andFilterWhere([
'p.id' => $this->id,
'p.category_id' => $this->category_id,
'p.designer_id' => $this->designer_id,
'p.price' => $this->price,
'p.new' => $this->new,
'p.hit' => $this->hit,
'p.sale' => $this->sale,
'p.created_at' => $this->created_at,
'p.updated_at' => $this->updated_at,
'pp.childrenProducts' => $this->childrenProducts
]);
А $letter подменяется на 1 букву и по каждой букве отдельный выбор не имеющий отношения к цифрам - только буквы
Если бы с цифрами было тоже по одной, то и без andWhere бы можно было массив собрать из 0-9 и a-z вместе и...
Или для каждой цыфры andWhere? Не сильно ли это костыльно будет?