title: How to save specific value in a field of DB in cakePHP 2.0?
body: <p>I'm trying to migrate CakePHP from 1.3 to 2.0. And now, I encounter a small problem regarding to inserting a value to a specific field. Here is the code in which I made in version 1.3:</p>
  
  <pre><code>function add() {
  
      if(isset($_SESSION['User']['id'])){ 
          if(!empty($this-&gt;data)) {
              if($this-&gt;Ad-&gt;save($this-&gt;data)){
  
                  //saving the uID in table ads
                  $this-&gt;data['Ad']['uID'] = $_SESSION['User']['id'];  
                  $this-&gt;data['Ad']['DatePosted'] = DboSource::expression('NOW()');     
                  $this-&gt;data['Ad']['IP'] = $_SERVER['REMOTE_ADDR'];   
                  $this-&gt;Ad-&gt;save($this-&gt;data, FALSE);                    
  
                  $this-&gt;Session-&gt;setFlash('The post was successfully added!');
                  $this-&gt;redirect(array('action'=&gt;'index'));
              }
              else{
              $this-&gt;Session-&gt;setFlash('The post was not saved. Please try again.', 'alert-message', array('class'=&gt;'error'));
              }               
          }
      }
      else{
          $this-&gt;Session-&gt;setFlash('You have to login first to access control panel');
          $this-&gt;redirect(array('controller'=&gt;'users','action'=&gt;'login'));
      }   
  
  
      //for setting the category of advertisement
      $adcats = $this-&gt;Ad-&gt;Adcat-&gt;find('list',array('fields'=&gt;array('id','Description')));
      $this-&gt;set(compact('adcats'));
  
      //for setting the type of advertisement
      $adtyps = $this-&gt;Ad-&gt;Adtyp-&gt;find('list',array('fields'=&gt;array('id','Description')));
      $this-&gt;set(compact('adtyps'));  
  
  }
  </code></pre>
  
  <p>Now, here is my code in which I want to include the user-ID (represents as uID), the post date (represents as DatePosted), and the IP address of the user.</p>
  
  <pre><code>public function add() {
  
      if($this-&gt;Session-&gt;read('user_id')){    
          if($this-&gt;request-&gt;is('post')) {
              if($this-&gt;Ad-&gt;save($this-&gt;request-&gt;data)){
  
                  //saving the uID in table ads
                  //$this-&gt;data['Ad']['uID'] = $this-&gt;Session-&gt;read('user_id');  
                  //$this-&gt;data['Ad']['DatePosted'] = DboSource::expression('NOW()');     
                  //$this-&gt;data['Ad']['IP'] = $_SERVER['REMOTE_ADDR'];   
  
                  $this-&gt;Ad-&gt;uID = $this-&gt;Session-&gt;read('user_id'); 
                  $this-&gt;Ad-&gt;DatePosted = DboSource::expression('NOW()');
                  $this-&gt;Ad-&gt;IP = $_SERVER['REMOTE_ADDR']; 
  
                  $this-&gt;Ad-&gt;save($this-&gt;request-&gt;data);                  
  
                  $this-&gt;Session-&gt;setFlash('The post was successfully added!');
                  $this-&gt;redirect(array('action'=&gt;'index'));
              }
              else{
              $this-&gt;Session-&gt;setFlash('The post was not saved. Please try again.', 'alert-message', array('class'=&gt;'error'));
              }               
          }
      }
      else{
          $this-&gt;Session-&gt;setFlash('You have to login first to access control panel');
          $this-&gt;redirect(array('controller'=&gt;'users','action'=&gt;'login'));
      }   
  
      //for setting the category of advertisement
      $adcats = $this-&gt;Ad-&gt;Adcat-&gt;find('list',array('fields'=&gt;array('id','Description')));
      $this-&gt;set(compact('adcats'));
  
      //for setting the type of advertisement
      $adtyps = $this-&gt;Ad-&gt;Adtyp-&gt;find('list',array('fields'=&gt;array('id','Description')));
      $this-&gt;set(compact('adtyps'));  
  
  }
  </code></pre>
  
  <p>Now, my question is how can I save those three fields that I mentioned it before?</p>