yiqiang
(Daiyqj)
1
I am confused about yii2 active record.
If i am not wrong, i think the php PDO binding param will auto escape the input before query the database.
My quesiton based on yii2 active record such as queries below
$customers = Customer::find()
->where(['status' => $status)
->orderBy('id')
->all();
will auto escape $status? or if not how can i bind param for this kind of query. Please also give an example on the create query.
Thanks.
vundicind
(Vundicind)
2
You can check it by yourself
:
$query = Customer::find()
->where(['status' => $status])
->orderBy('id');
$command = $query->createCommand();
echo $command->rawSql;
yiqiang
(Daiyqj)
3
strange using your quote, i get an error "Call to a member function createCommand() on a non-object"
zelenin
(Aleksandr)
4
You should read documentation, then write your questions
there are examples with params binding.
shoneZ89
(Nenad Z)
5
I’ve made post with similar question, and answer is : yii will auto escape and bind.
You can read about it here.
omeraslam
(Buttflattery)
6
which link ? you never posted the link