3
$aa = India::find();
$players = $aa
            ->where('player LIKE :query', [':query'=>'S%'])
            ->orderBy('position, player')->all();
$countnumber = $aa->count();

This code returns results without case sensitivity. Gives results where Player name starts with 'S' or 's'.

But I want to make, just to select Player names only with 'S'. How to restrict it to select with case sensitivity in PHP Yii2 Framworok ?

sorak
  • 2,587
  • 2
  • 14
  • 24

1 Answers1

3

In case you are using MySQL you can make your query with BINARY

So your Yii2 code should be something like this:

$players = India::find()
            ->where(['LIKE BINARY', 'player', $query_parameter])
            ->orderBy('position, player')->all();
s_mart
  • 705
  • 7
  • 21