S
S
Sergey Beloventsev2017-02-02 21:53:40
Yii
Sergey Beloventsev, 2017-02-02 21:53:40

Explain what's wrong with requests?

here is the query

$cat= Category::find()->where(['or',['parrent_category'=>0],['parrent_category'=>null]])->all();
var_dump($cat)

produces
null
I go to the debugger and take a query to the database from there
SELECT * FROM `category` WHERE (`parrent_category`=0) OR (`parrent_category` IS NULL)

I make it out through the same phpmyadmin I get at least 10 values. I make round eyes and do not understand what the problem is.
Please explain how it can be that a mysql query would return 10 values ​​and an ActiveRecord query would return none?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lander, 2017-02-02
@Sergalas

$cat= Category::find()->where(['or',['parrent_category'=>0],['is', 'parrent_category', null]])->all();

D
Dmitry, 2017-02-02
@slo_nik

Good evening.

$cat= Category::find()->where(['or', 'parrent_category=0' ,'parrent_category is null'])->all();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question