Note that there are some explanatory texts on larger screens.

plurals
  1. POCakephp 2.4 version not updating data in the datsbase
    primarykey
    data
    text
    <p>I am creating app for reservation which will create request for pickup and for that i am sending all fields to my action of request Controller but that is not saving data into database. i am unable to figure out the issue in it. The code for that controller is </p> <pre><code> public function create() { $this-&gt;layout=''; if ($this-&gt;request-&gt;is('post')) { $this-&gt;Request-&gt;create(); $get_Count = $this-&gt;Request-&gt;find('count'); $get_Count=$get_Count+1; $this-&gt;request-&gt;data['Latitude'] = floatval($this-&gt;request-&gt;data['Latitude']); $this-&gt;request-&gt;data['Longitude'] = floatval($this-&gt;request-&gt;data['Longitude']); $this-&gt;request-&gt;data['Country'] = $this-&gt;request-&gt;data['Country']; $this-&gt;request-&gt;data['City'] = $this-&gt;request-&gt;data['City']; $this-&gt;request-&gt;data['Postal_Code'] = $this-&gt;request-&gt;data['Postal_Code']; $this-&gt;request-&gt;data['Mobile_Number'] = $this-&gt;request-&gt;data['Mobile_Number']; $this-&gt;request-&gt;data['Current_Status'] = (int) $this-&gt;request-&gt;data['Current_Status']; $this-&gt;request-&gt;data['Created_Date'] = date("d/m/Y"); $this-&gt;request-&gt;data['Modified']=false; $this-&gt;request-&gt;data['Total_Km']=0.0; $this-&gt;request-&gt;data['Price_Per_Km']=0; $this-&gt;request-&gt;data['Total_Price']=0; $this-&gt;request-&gt;data['Type'] = (int) $this-&gt;request-&gt;data['Type']; //$this-&gt;request-&gt;data['Id']=$get_Count; $p=(int) $this-&gt;request-&gt;data['Passenger'];; $this-&gt;request-&gt;data['Passenger'] = $p; $this-&gt;request-&gt;data['Driver']=0; $this-&gt;request-&gt;data['Pick_Up'] = $this-&gt;request-&gt;data['Pick_Up']; $this-&gt;request-&gt;data['Drop_Off'] = $this-&gt;request-&gt;data['Drop_Off']; $this-&gt;request-&gt;data['Modified_By'] = 0; if ($this-&gt;Request-&gt;save($this-&gt;request-&gt;data)) { $this-&gt;request-&gt;data['Status']=1; $this-&gt;request-&gt;data['Request_Id']=$get_Count; echo json_encode($this-&gt;request-&gt;data); return; } else { $this-&gt;request-&gt;data['Status']=0; echo json_encode($this-&gt;request-&gt;data); $this-&gt;Session-&gt;setFlash(__('The request could not be saved. Please, try again.')); } } } </code></pre> <p>It's Model is as</p> <pre><code> &lt;?php App::uses('AppModel', 'Model'); /** * Request Model * */ class Request extends AppModel { /** * Validation rules * * @var array */ public $validate = array( 'Country' =&gt; array( 'notempty' =&gt; array( 'rule' =&gt; array('notempty'), //'message' =&gt; 'Your custom message here', //'allowEmpty' =&gt; false, //'required' =&gt; false, //'last' =&gt; false, // Stop validation after this rule //'on' =&gt; 'create', // Limit validation to 'create' or 'update' operations ), ), 'City' =&gt; array( 'notempty' =&gt; array( 'rule' =&gt; array('notempty'), //'message' =&gt; 'Your custom message here', //'allowEmpty' =&gt; false, //'required' =&gt; false, //'last' =&gt; false, // Stop validation after this rule //'on' =&gt; 'create', // Limit validation to 'create' or 'update' operations ), ), 'Postal_Code' =&gt; array( 'notempty' =&gt; array( 'rule' =&gt; array('notempty'), //'message' =&gt; 'Your custom message here', //'allowEmpty' =&gt; false, //'required' =&gt; false, //'last' =&gt; false, // Stop validation after this rule //'on' =&gt; 'create', // Limit validation to 'create' or 'update' operations ), ), 'Mobile_Number' =&gt; array( 'notempty' =&gt; array( 'rule' =&gt; array('notempty'), //'message' =&gt; 'Your custom message here', //'allowEmpty' =&gt; false, //'required' =&gt; false, //'last' =&gt; false, // Stop validation after this rule //'on' =&gt; 'create', // Limit validation to 'create' or 'update' operations ), ), 'Current_Status' =&gt; array( 'numeric' =&gt; array( 'rule' =&gt; array('numeric'), //'message' =&gt; 'Your custom message here', //'allowEmpty' =&gt; false, //'required' =&gt; false, //'last' =&gt; false, // Stop validation after this rule //'on' =&gt; 'create', // Limit validation to 'create' or 'update' operations ), ), 'Created_Date' =&gt; array( 'date' =&gt; array( 'rule' =&gt; array('date'), //'message' =&gt; 'Your custom message here', //'allowEmpty' =&gt; false, //'required' =&gt; false, //'last' =&gt; false, // Stop validation after this rule //'on' =&gt; 'create', // Limit validation to 'create' or 'update' operations ), ), 'Modified' =&gt; array( 'boolean' =&gt; array( 'rule' =&gt; array('boolean'), //'message' =&gt; 'Your custom message here', //'allowEmpty' =&gt; false, //'required' =&gt; false, //'last' =&gt; false, // Stop validation after this rule //'on' =&gt; 'create', // Limit validation to 'create' or 'update' operations ), ), 'Price_Per_Km' =&gt; array( 'numeric' =&gt; array( 'rule' =&gt; array('numeric'), //'message' =&gt; 'Your custom message here', //'allowEmpty' =&gt; false, //'required' =&gt; false, //'last' =&gt; false, // Stop validation after this rule //'on' =&gt; 'create', // Limit validation to 'create' or 'update' operations ), ), 'Type' =&gt; array( 'numeric' =&gt; array( 'rule' =&gt; array('numeric'), //'message' =&gt; 'Your custom message here', //'allowEmpty' =&gt; false, //'required' =&gt; false, //'last' =&gt; false, // Stop validation after this rule //'on' =&gt; 'create', // Limit validation to 'create' or 'update' operations ), ), 'Id' =&gt; array( 'numeric' =&gt; array( 'rule' =&gt; array('numeric'), //'message' =&gt; 'Your custom message here', //'allowEmpty' =&gt; false, //'required' =&gt; false, //'last' =&gt; false, // Stop validation after this rule //'on' =&gt; 'create', // Limit validation to 'create' or 'update' operations ), ), 'Passenger' =&gt; array( 'numeric' =&gt; array( 'rule' =&gt; array('numeric'), //'message' =&gt; 'Your custom message here', //'allowEmpty' =&gt; false, //'required' =&gt; false, //'last' =&gt; false, // Stop validation after this rule //'on' =&gt; 'create', // Limit validation to 'create' or 'update' operations ), ), 'Driver' =&gt; array( 'numeric' =&gt; array( 'rule' =&gt; array('numeric'), //'message' =&gt; 'Your custom message here', //'allowEmpty' =&gt; false, //'required' =&gt; false, //'last' =&gt; false, // Stop validation after this rule //'on' =&gt; 'create', // Limit validation to 'create' or 'update' operations ), ), 'Pick_Up' =&gt; array( 'notempty' =&gt; array( 'rule' =&gt; array('notempty'), //'message' =&gt; 'Your custom message here', //'allowEmpty' =&gt; false, //'required' =&gt; false, //'last' =&gt; false, // Stop validation after this rule //'on' =&gt; 'create', // Limit validation to 'create' or 'update' operations ), ), 'Drop_Off' =&gt; array( 'notempty' =&gt; array( 'rule' =&gt; array('notempty'), //'message' =&gt; 'Your custom message here', //'allowEmpty' =&gt; false, //'required' =&gt; false, //'last' =&gt; false, // Stop validation after this rule //'on' =&gt; 'create', // Limit validation to 'create' or 'update' operations ), ), 'Modified_By' =&gt; array( 'numeric' =&gt; array( 'rule' =&gt; array('numeric'), //'message' =&gt; 'Your custom message here', //'allowEmpty' =&gt; false, //'required' =&gt; false, //'last' =&gt; false, // Stop validation after this rule //'on' =&gt; 'create', // Limit validation to 'create' or 'update' operations ), ), ); </code></pre> <p>}</p> <p>Android Output in LogCat is </p> <blockquote> <p>12-11 01:20:17.073: I/System.out(26832): Setting the contents of the Reader 12-11 01:20:17.133: I/System.out(26832): {"Latitude":31.4685541,"Longitude":74.3374621,"Country":"Pakistan","City":"Lahore","Postal_Code":"54700","Mobile_Number":"03227658594","Current_Status":3,"Type":1,"Passenger":1,"Pick_Up":"uugfdjgsdh","Drop_Off":"vjjffjjffjkkfg","Created_Date":"10/12/2013","Modified":false,"Total_Km":0,"Price_Per_Km":0,"Total_Price":0,"Id":1,"Driver":0,"Modified_By":0,"Status":0} 12-11 01:20:17.133: I/System.out(26832): I am in try block of json final result reading</p> </blockquote> <p>I am getting the Status 0 on Android Device.Its View is empty.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload