Skip to main content

Posts

Showing posts from December, 2014

Cakephp testimonials

CakePHP testimonials Components and Plugins are still separate entities in Cake 2.0. According to the manual components are " are packages of logic that are shared between controllers ", whereas plugins are "a combination of controllers, models, and views". Compoments extend the base Component class, while Plugins have their own AppModel and AppController. Think of a plugin as a separate Cake application sharing the same core libraries with your main application. How to use vendor in cakephp App::import('Vendor', 'Custom/getdata'); $obj = new GetData(); Lib Contains 1st party libraries that do not come from 3rd parties or external vendors. This allows you to separate your organization’s internal libraries from vendor libraries. Vendor Any third-party classes or libraries should be placed here. Doing so makes them easy to access using the App::import(‘vendor’, ‘name’) function. Keen observers will note that this seems redundant, as ther...

Cakephp redirection

CakePHP Redirection Redirecting: $this->redirect(array('controller' => 'orders', 'action' => 'thanks')); Redirecting to website: $this->redirect('http://www.example.com'); Render the element for ajax: $this->render('/Elements/ajaxreturn'); Redirect to 404 not found: throw new NotFoundException('404 Error - Page not found'); If you need to redirect to the referer page you can use: $this -> redirect ( $this -> referer ()); If you need to redirect to the edit page with id: $this -> redirect ( array ( ’action’ => ’edit’ , $id )); Redirect to different action: $this -> render ( ’custom_file’ ); Call element in controller action $this->viewPath = 'Elements'; $this->render('sub_cat_list');       

Cakephp Model Query

Cakephp Model Fetch query Retrieve data from database $this->Resume->find('first',array('contain'=>array('ResumeSkill'=>array('Skill'=>array('name'), 'conditions'=>array('ResumeSkill.skill_id !='=>''))), 'conditions'=>array('Resume.user_id'=>$user_id),'order'=>'Resume.modified DESC')); $this->Layout->query("SELECT *,if(sort IS NULL,0,sort) as sort1  FROM `layouts` AS Layout WHERE `user_id` LIKE '".$user_id."' && Layout.active=1 ORDER BY (`sort1`>0) DESC,(`sort1`) ASC"); $this->Invoice->find('first',array('fields'=>array('*','curdate() as curdate','DATE_FORMAT(plan_start_date,"%Y-%m-%d") as plan_start_date1'), 'conditions'=>array('Invoice.id'=>$last_invoice_id,'Invoice.user_id'=>$this->Auth->user('id') ,...