Hi,
i have concated two columns.but its filetering and searching is not working.
my code for controller
public $client_name;
$criteria->compare(‘CONCAT(first_name,last_name)’,$this->client_name,true);
my code for view
array(
'header'=>'Client Name',
'name'=>'client_name',
'value'=>'$data->first_name." ".$data->last_name',
),
Concatenation and displaying is done but seraching the data show no results found?
plz help.thanks in advance.
Keith
(Kburton)
2
Have you updated your model’s search method?
yes i updated the search method as
$criteria->compare(‘CONCAT(first_name,last_name)’,$this->first_name,true);
Bianca
(Biancajsen)
4
Try
$criteria->compare('CONCAT_WS(' ',first_name,last_name)',$this->client_name,true);
If client_name is not an attribute in your db, declare it in your model as
public $client_name
Add it also as safe on search in your model
yes i declare it as
public $client_name
and add it in safe search as
array(‘id, first_name, last_name, email_address,client_name’, ‘safe’, ‘on’=>‘search’),
and in search() criteria as
$criteria->compare(‘CONCAT_WS(’ ‘,first_name,last_name)’,$this->client_name,true);
and in cgrigview as
array(
'header'=>'Client Name',
'name'=>'client_name',
'value'=>'$data->first_name." ".$data->last_name',
),
But the error Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING $criteria->compare(‘CONCAT_WS(’ ‘,first_name,last_name)’,$this->client_name,true);
plz reply thanks
Keith
(Kburton)
6
Replace either the inner or outer single quotes with double quotes:
$criteria->compare('CONCAT_WS(" ",first_name,last_name)',$this->client_name,true);
@ Jimlam and @Keith. i done it with the change of single quotes to double quotes in this life of code.
from
$criteria->compare(‘CONCAT_WS(’ ‘,first_name,last_name)’,$this->client_name,true);
to
$criteria->compare(‘CONCAT_WS(" ",first_name,last_name)’,$this->client_name,true);
Thanks for all .well done.