To find record in yii2 I use following code:
$response = Response::findOne(['unique_url' => $unique_url]);
But it return record regardless $unique_url
case.
How to do it case sensitive?
I think you should use LIKE BINARY
and for this you should extended you modelSearch adding the clause in query condition
public function search($params)
{
$query = YuorModel::find();
.......
.......
$query->andFilterWhere(['like binary', 'unique_url', $this->unique_url])
->andFilterWhere(['like', 'your_field2', $this->your_field2])
.......
Best solution which I found for this:
Response::find()->where('BINARY [[unique_url]]=:unique_url', ['unique_url'=>$unique_url])->one();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With