yii2 active record bind parameter

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.

You can check it by yourself :




$query = Customer::find()

->where(['status' => $status])

->orderBy('id');

$command = $query->createCommand();

echo $command->rawSql;



strange using your quote, i get an error "Call to a member function createCommand() on a non-object"

You should read documentation, then write your questions

there are examples with params binding.

I’ve made post with similar question, and answer is : yii will auto escape and bind.

You can read about it here.

which link ? you never posted the link