Search Problem

Hi,

I have problem with SQL String of Search Function.

Sorry but i know little yii2.

I’have two table

Registry(id, name,surname,date_birthday,city_id)

City (id,citta_id) with hasOne relation

This is my incomplate code because I did not understand syntax code.

public function search($params)

{

$query = Registry::find();

$query->joinWith([‘city’]);

$dataProvider = new ActiveDataProvider([‘query’ => $query,]);

$dataProvider->setSort([

‘attributes’ => [

‘date_birthday’,

‘nomeSurname’ => [

‘asc’ => [‘surname’ => SORT_ASC, ‘name’ => SORT_ASC],

‘desc’ => [‘surname’ => SORT_DESC, ‘name’ => SORT_DESC],

‘default’ => SORT_ASC

],

‘nameCity’ => [

‘asc’ => [‘city.city’ => SORT_ASC],

‘desc’ => [‘city.city’ => SORT_DESC],

]

]

]);

if (!($this->load($params) && $this->validate()))

{

return $dataProvider;

}

$query->andWhere(‘surname LIKE "%’ . $this->nameSurname . '%" ’ .

‘OR nameLIKE "%’ . $this->nameSurname . ‘%"’

)

andWhere(‘city.cityLIKE "%’ . $this->nameCity. '%" ')

andWhere(‘date_birthday ="’ . $this->birthday . ‘"’);

return $dataProvider;