Search function for application
Hello, I am using CakePHP in a project and would like to integrate a 'search' function. I'm not talking about a full index for the site (like htdig), but mainly a search function for specific fields. e.g. search for a person by name etc.. I'm not sure what's the best way to do this. 1. Create a model 'search' with no table and execute something like SELECT FROM table WHERE value LIKE '%searchvalue%' for each field I'd like to search. 2. integrate a 'search' function into each controller of the existing models. Has somebody done something like this before and would like to share his experience or link to some example code? In the archive and bakery I can hardly find anything about this topic.. Best regards Ralph --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Search function for application
In your controller If (isset($this-data['User']['username'])) { $user = $this-User-findByUsername($this-data['User']['username']); } If its a search controller, rather than in the users controller you need to make sure you delare $uses at the top of the contoller $uses = array('User'); As long as your table fields follow cake conventions you can do any findByField(), check out the API docs for more info on it Tane On 4/11/07, szeta [EMAIL PROTECTED] wrote: Hello, I am using CakePHP in a project and would like to integrate a 'search' function. I'm not talking about a full index for the site (like htdig), but mainly a search function for specific fields. e.g. search for a person by name etc.. I'm not sure what's the best way to do this. 1. Create a model 'search' with no table and execute something like SELECT FROM table WHERE value LIKE '%searchvalue%' for each field I'd like to search. 2. integrate a 'search' function into each controller of the existing models. Has somebody done something like this before and would like to share his experience or link to some example code? In the archive and bakery I can hardly find anything about this topic.. Best regards Ralph --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
RE: Search function for application
If you have a UsersController and a User model created, then there's no need to declare $uses. The CamelCase of the singular version of the controller name will be automatically linked as the main model of your controller when not declaring $uses. -MI --- Remember, smart coders answer ten questions for every question they ask. So be smart, be cool, and share your knowledge. BAKE ON! blog: http://www.MarianoIglesias.com.ar -Mensaje original- De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre de digital spaghetti Enviado el: MiƩrcoles, 11 de Abril de 2007 05:23 a.m. Para: cake-php@googlegroups.com Asunto: Re: Search function for application If its a search controller, rather than in the users controller you need to make sure you delare $uses at the top of the contoller --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Search function for application
I personally use a 3rd party script as a vendor for doing my searching. I think the vendor feature is very much overlooked. Combining the power of some simple yet powerful little scripts out there with CakePHP really allows for rapid development of robust applications. Anyway, check out my research here: http://www.concepthue.com/how-to/cake_search_vendor/ Quite easy to setup and I've found it effective. There are of course other 3rd party scripts you can use instead. -Tom On Apr 11, 4:45 am, Mariano Iglesias [EMAIL PROTECTED] wrote: If you have a UsersController and a User model created, then there's no need to declare $uses. The CamelCase of the singular version of the controller name will be automatically linked as the main model of your controller when not declaring $uses. -MI --- Remember, smart coders answer ten questions for every question they ask. So be smart, be cool, and share your knowledge. BAKE ON! blog:http://www.MarianoIglesias.com.ar -Mensaje original- De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] En nombre de digital spaghetti Enviado el: MiƩrcoles, 11 de Abril de 2007 05:23 a.m. Para: [EMAIL PROTECTED] Asunto: Re: Search function for application If its a search controller, rather than in the users controller you need to make sure you delare $uses at the top of the contoller --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to [EMAIL PROTECTED] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---