Skip to main content

Posts

Cakephp Email Setting

Basic usage First of all, you should ensure the class is loaded using App::uses(): App::uses('CakeEmail', 'Network/Email'); Using CakeEmail is similar to using EmailComponent. But instead of using attributes you use methods. Example: $Email = new CakeEmail(); $Email->from(array('me@example.com' => 'My Site')); $Email->to('you@example.com'); $Email->subject('About'); $Email->send('My message'); To enable the transport, add the following information to your Config/email.php: You can configure SSL SMTP servers such as Gmail. To do so, prefix the host with 'ssl://' and configure the port value accordingly. Example: class EmailConfig {     public $gmail = array(         'host' => 'ssl://smtp.gmail.com',         'port' => 465,         'username' => 'my@gmail.com',         'password' => 'secret',         'transport' =...

PHP OOPS Concept

Encapsulation: Encapsulation is the mechanism that binds together code and the data it manipulates, and keeps both safe from outside interference and misuse. The wrapping up of data and methods into a single unit (called class) is known as encapsulation. The benefit of encapsulating is that it performs the task inside without making you worry. Polymorphism : Objects could be of any type. A discrete object can have discrete properties and methods which work separately to other objects. However a set of objects could be derived from a parent object and retain some properties of the parent class. This process is called polymorphism. An object could be morphed into several other objects retaining some of its behavior. Inheritance : The key process of deriving a new object by extending another object is called inheritance. When you inherit an object from another object, the subclass (which inherits) derives all the properties and methods of the superclass (which is inherited). A s...

PHP IMAP

**  * Uses PHP IMAP extension, so make sure it is enabled in your php.ini,  * extension=php_imap.dll  */  set_time_limit(3000);  /* connect to gmail with your credentials */ $hostname = '{imap.gmail.com:993/imap/ssl}INBOX'; $username = 'YOUR_GMAIL_USERNAME'; # e.g somebody@gmail.com $password = 'YOUR_GMAIL_PASSWORD'; /* try to connect */ $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error()); $emails = imap_search($inbox,'ALL'); /* useful only if the above search is set to 'ALL' */ $max_emails = 16; /* if any emails found, iterate through each email */ if($emails) {     $count = 1;         /* put the newest emails on top */     rsort($emails);         /* for every email... */     foreach($emails as $email_number)     {         /* get information specific to this email */   ...

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') ,...