Thanks Issac for the reply.. Let me ask one more thing that, I need to use different tables (like user, potentail user, and subscribed user ), for the functionality. Is it possible with your solution ? If so how can i do it.. Can you give me an example (code) for that .?
On Tue, Jul 21, 2009 at 7:42 AM, Isaac Raja <isaacr...@gmail.com> wrote: > Hi bino dev, > > since you are using a searches controller, and you are using a line like > this > > $data = $this->Search->findAll($sql , NULL, $order, $limit, $page); > > > you need to create a Search model.(with searches table) > > > Actually it is not necessary to create searches controller and its view. > you need to include a search method in the controller which you want to > search. > > For example, if you want to seach the products table, create a method > search in products controller and a model Product. > > > Thanks > Isaac Raja > > > On Tue, Jul 21, 2009 at 2:35 AM, bino dev <biy....@gmail.com> wrote: > >> Hi, >> >> Please help me. >> Friends i need to create one search page, its searching with company , >> first name, lastname, email >> i created the view , controller for the functionality. Do i need to >> create any model for it. Iam getting the error if there is no model in it.If >> i need to create the model , what should be the $name in the model. >> >> searchs_controller.php ( http://bin.cakephp.org/view/243917622 ) >> >> <?php >> class SearchsController extends AppController >> { >> >> //var $uses = array('search'); >> >> var $name = 'Search'; >> >> var $useTable = false; >> >> function admin_index() >> { >> >> if(isset($this->params['url']['data'])) { >> echo $this->params['url']['data']['searchs']['first_name']; >> echo $this->params['url']['data']['searchs']['last_name']; >> echo $this->params['url']['data']['searchs']['company']; >> echo $this->params['url']['data']['searchs']['email']; >> echo $this->params['url']['data']['searchs']['phone']; >> echo $this->params['url']['data']['searchs']['address']; >> >> >> $datass = "user.status = 1 "; >> >> if($this->params['url']['data']['searchs']['first_name'] !='') >> { >> $datass .= " and user.first_name like >> '%".$this->params['url']['data']['searchs']['first_name']."%'"; >> } >> >> if($this->params['url']['data']['searchs']['last_name'] !='') { >> $datass .= " and user.last_name like >> '%".$this->params['url']['data']['searchs']['last_name']."%'"; >> } >> >> >> if($this->params['url']['data']['searchs']['email'] !='') { >> $datass .=" and user.email like >> '%".$$this->params['url']['data']['searchs']['email'] ."%'"; >> } >> >> >> //list($order,$limit,$page) = $this->Pagination->init($datass); >> >> //pr($this->params); >> >> $sql = array('conditions' => array($datass), >> 'recursive' => 1 , >> 'fields' => array('Search.username, Search.first_name, >> Search.last_name, Search.email, Search.status, Search.created, >> Search.modified'), >> 'order' => array( 'Search.created DESC'), >> 'limit' => $limit, >> 'page' => $page >> ); >> } >> $data = $this->Search->findAll($sql , NULL, $order, $limit, >> $page); >> $this->set('userdetails', $data); >> >> } >> >> } >> ?> >> >> view page http://bin.cakephp.org/view/311196886 >> >> <?php $this->setLayout('admin'); ?> >> <script type="text/javascript"> >> jQuery(document).ready(function($) { >> $('.roundbox').hover( >> function(){$('.roundbox ul').show();}, >> function(){$('.roundbox ul').hide();} >> ); >> }); >> </script> >> <style> >> #sidebar { >> background-color: white; >> position: absolute; >> top: 84px; >> right: 20px; >> z-index: 999; >> } >> .roundbox ul { >> display: none; >> } >> #main { >> width: 100%; >> padding-top:15px; >> } >> </style> >> <div id="sidebar"> >> <div class="roundbox"> >> <h2>Sub Menu</h2> >> <ul class="actions"> >> <li> </li> >> <li><?php echo $html->link('Export current items in CSV >> format', '/admin/potential_suppliers/export'); ?></li> >> <li> </li> >> </ul> >> </div> >> </div> >> <div id="main"> >> <h2>List Potential Suppliers</h2> >> <br /> >> <?php >> //$pagination->setPaging($paging); >> // echo ($filter->setFiltering($filters)); >> ?> >> >> >> >> <form action="" method="get" class="uniForm"> >> <table border="0"> >> <tr> >> <td><?php echo $form->labelTag('searchs/first_name', 'First Name');?></td> >> <td> <?php echo $html->input('searchs/first_name', >> array('size'=>'35','class'=>'textInput'));?> >> <?php echo $html->tagErrorMsg('searchs/first_name', 'Please enter >> first_name.');?> >> </td> >> >> <td> >> <?php echo $form->labelTag('searchs/last_name', 'Last >> Name');?> >> </td> >> <td> <?php echo $html->input('searchs/last_name', >> array('size'=>'35','class'=>'textInput'));?> >> <?php echo $html->tagErrorMsg('searchs/last_name', 'Please >> enter Last Name');?> >> </td> >> <tr> >> <td> >> <?php echo $form->labelTag('searchs/company', 'Company >> Name');?> >> </td> >> <td> <?php echo $html->input('searchs/company', >> array('size'=>'35','class'=>'textInput'));?> >> <?php echo $html->tagErrorMsg('searchs/company', 'Please enter >> Company.');?> >> </td> >> >> >> <td> >> >> <?php echo $form->labelTag('searchs/email', 'E-mail >> Aaddress');?> >> </td> >> <td> <?php echo $html->input('searchs/email', >> array('size'=>'35','class'=>'textInput'));?> >> <?php echo $html->tagErrorMsg('searchs/email', 'Please enter >> E-mail Address.');?> >> </td> >> </tr> >> <tr> >> <td> >> >> <?php echo $form->labelTag('searchs/phone', 'Phone');?> >> </td> >> <td> <?php echo $html->input('searchs/phone', >> array('size'=>'35','class'=>'textInput'));?> >> <?php echo $html->tagErrorMsg('searchs/phone', 'Please enter >> phone number.');?> >> </td> >> >> <td> >> >> <?php echo $form->labelTag('searchs/address', 'Address');?> >> </td> >> <td> <?php echo $html->input('searchs/address', >> array('size'=>'35','class'=>'textInput'));?> >> <?php echo $html->tagErrorMsg('searchs/address', 'Please enter >> Address.');?> >> </td> >> </tr> >> <tr> >> <td align="right"> >> <div class="buttonHolder"> >> <?php echo $html->submit('Search');?> >> </div> >> </td> >> </tr> >> </fieldset> >> </table> >> </form> >> >> >> <br /> >> <?php //echo $this->renderElement('pagination'); ?> >> </div> >> >> >> >> > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---