"AND `User.name, User.email,
Profile.name, Profile.phone` LIKE"
Profile.name, Profile.phone` LIKE"
is invalid SQL which you get when you do it wrong.
The correct approach as outlined in the readme is to use the array syntax:
'field' => array('User.name', 'User.email', 'Profile.name', 'Profile.phone')
Note that you got 4 array elements here instead of one long one as in your case.
Am Donnerstag, 28. März 2013 20:33:20 UTC+1 schrieb Sergio Eustaquio Pereda Saviñón:
> > with my bugfixed and enhanced version you
can:https://github.com/dereuromark/search
>
> > but you should use an array structure then - like that:
>
> > 'field'=>array('Model1.entry1', 'Model1.entry2',
> > 'Model2.entry2', ...)
>
I'm using Cakephp V 2.3.1, and the plugin from Dereuromark branch fixed.
Im getting this error:
Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'User.name,
User.email, Profile.name, Profile.phone' in 'where clause'
Database error:
SQL Query: SELECT `User`.`id`, `User`.`name`, `User`.`email`,
`User`.`password`, `User`.`login_id`, `User`.`profile_id`,
`User`.`activate`, `User`.`is_sadmin`, `User`.`ubuildinghive`,
`User`.`ustaff`,
...
`Profile`.`name`, `Profile`.`email2`, `Profile`.`app`, `Profile`.`apm`,
`Profile`.`phone`,
....
`Pbpermission`.`advertising`, `Pbpermission`.`techsupport`,
`Pbpermission`.`company`,
....
FROM `buildhive`.`users` AS `User` LEFT JOIN `buildhive`.`profiles` AS
`Profile` ON (`User`.`profile_id` = `Profile`.`id`) LEFT JOIN
`buildhive`.`pbpermissions` AS `Pbpermission` ON (`User`.`pbpermission_id` =
`Pbpermission`.`id`) **WHERE `ubuildinghive` = 1 AND `User.name, User.email,
Profile.name, Profile.phone` LIKE '%adf%' LIMIT 20
User Model:
public $actsAs = array('Search.Searchable', 'Containable');
public $filterArgs = array(
'pbpermission_id' => array('type' => 'like'),
'search_email' => array('type' => 'like', 'field' => 'User.email'),
'pname' => array('type' => 'like', 'field' => 'Profile.name'),
'phone' => array('type' => 'like', 'field' => 'Profile.phone'),
'advanced' => array('type' => 'like', 'encode' => true, 'field' =>
array('User.name, User.email, Profile.name, Profile.phone') )
);
User Controller:
CakePlugin::load( array('Search') );
public $components = array('Search.Prg');
public $presetVars = true;
public function index:
$this->Prg->commonProcess();
$this->paginate = array('User' => array('contain' => array('Profile',
'Pbpermission') ) );
$conditions = array('ubuildinghive' => 1 );
$options = array_merge($conditions,
$this->User->parseCriteria($this->passedArgs) );
$users = $this->paginate('User', $options );
Please help !!!!,
--
View this message in context: http://cakephp.1045679.n5.nabble.com/CakeDC-Search- Plugin-How-to-search-2-fields- in-DB-using-only-1-form-field- tp5164502p5714305.html
Sent from the CakePHP mailing list archive at Nabble.com.
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment