M
M
Messi2017-02-14 10:36:45
Yii
Messi, 2017-02-14 10:36:45

How to properly bindParam() in Yii1?

There are JSON format records in the table, you need to find data in these records by condition.
I did Yii::app()->db->createCommand(), then select, from and add a condition:
andWhere('myTable.json LIKE \'%"phone":"' . $this->getPhone() . '"%\'');
This option works, but I need to do it with bindParam(),
andWhere('myTable.json LIKE \'%"phone"\:":searchPhone"%\'',[
':searchPhone' => $this-> getPhone()
]);
I get the error invailid parameter number: number of bound variables does not mathc number of tokens
What could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Max, 2017-02-14
@FitTech

andWhere(['like', 'json', '%'. $this->getPhone() .'%'])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question