Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Save data using cakephp

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 354
    Comment on it

    CakePHP will save model data as a snap to your database, User's Data will be ready to be saved in database it should be passed to the model’s save() method using this, in the giving format below. This is Controller action that uses a Cakephp model for saving the values to the database table. When data will be saved into the database this data will go through the first parameter using data validation mechanism. For exmaple using _call and set() function. This will flash a message into the screen that your data have been sucessfully saved.

     

    <?php
    
    App::uses('AppController', 'Controller')
    class PagesController extends AppController {
    
      public $name = 'Pages';
      public $uses = array('SaveData');
     
      public $helpers = array('Js' => array('Jquery'));
    
    
        public function index() {
        
          if(!empty($this->data))
        {
          /* Save data code */
                if($this->SaveData->save($this->data))
                {
                    $this->Session->setFlash(__('Form data saved Successfully'));
                    $this->Session->setFlash('your data has been Saved successfully!');
                    return $this->redirect('/User');
                    
                }
            }  
      }
    }
    
    ?>

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: