What to do when queryScalar() return false stored in DB

(SohelAhmed) #1

This is note.
Taken from discussion from slack channel

yii\db\Command->queryScalar() returns string, null or false
false means that there is no result at all
but what if the result is boolean and is actually false?
how do you handle this case?


that is the same issue as with caching a false value. You can not distinguish the cases.
To solve this you can use queryOne(), which will return an array in case of success or false in case of no result
your boolean is then inside of the array