Cakephp 2.4版本不更新数据库中的数据

时间:2013-12-10 20:17:37

标签: cakephp cakephp-2.0

我正在创建预订应用程序,这将创建取件请求,并且我将所有字段发送到我的请求控制器的操作,但这不是将数据保存到数据库中。我无法弄清楚它的问题。该控制器的代码是

 public function create() {
    $this->layout='';
    if ($this->request->is('post')) {
        $this->Request->create();
        $get_Count = $this->Request->find('count');
        $get_Count=$get_Count+1;
        $this->request->data['Latitude'] = floatval($this->request->data['Latitude']);
        $this->request->data['Longitude'] = floatval($this->request->data['Longitude']);
        $this->request->data['Country'] = $this->request->data['Country'];
        $this->request->data['City'] = $this->request->data['City'];
        $this->request->data['Postal_Code'] = $this->request->data['Postal_Code'];
        $this->request->data['Mobile_Number'] = $this->request->data['Mobile_Number'];
        $this->request->data['Current_Status'] = (int) $this->request->data['Current_Status'];
        $this->request->data['Created_Date'] = date("d/m/Y");
        $this->request->data['Modified']=false;
        $this->request->data['Total_Km']=0.0;
        $this->request->data['Price_Per_Km']=0;
        $this->request->data['Total_Price']=0;
        $this->request->data['Type'] = (int) $this->request->data['Type'];
        //$this->request->data['Id']=$get_Count;
        $p=(int) $this->request->data['Passenger'];;
        $this->request->data['Passenger'] = $p;
        $this->request->data['Driver']=0;       
        $this->request->data['Pick_Up'] = $this->request->data['Pick_Up'];
        $this->request->data['Drop_Off'] = $this->request->data['Drop_Off'];
        $this->request->data['Modified_By'] = 0;
         if ($this->Request->save($this->request->data)) {
             $this->request->data['Status']=1;
             $this->request->data['Request_Id']=$get_Count;
             echo json_encode($this->request->data);
             return;

        } else {
             $this->request->data['Status']=0;
             echo json_encode($this->request->data);
            $this->Session->setFlash(__('The request could not be saved. Please, try again.'));
        }
    }
}

它的模型是

   <?php
 App::uses('AppModel', 'Model');
 /**
 * Request Model
 *
 */
 class Request extends AppModel {

 /**
 * Validation rules
 *
 * @var array
*/
public $validate = array(
    'Country' => array(
        'notempty' => array(
            'rule' => array('notempty'),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or        'update' operations
        ),
    ),
    'City' => array(
        'notempty' => array(
            'rule' => array('notempty'),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'Postal_Code' => array(
        'notempty' => array(
            'rule' => array('notempty'),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'Mobile_Number' => array(
        'notempty' => array(
            'rule' => array('notempty'),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'Current_Status' => array(
        'numeric' => array(
            'rule' => array('numeric'),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'Created_Date' => array(
        'date' => array(
            'rule' => array('date'),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'Modified' => array(
        'boolean' => array(
            'rule' => array('boolean'),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'Price_Per_Km' => array(
        'numeric' => array(
            'rule' => array('numeric'),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'Type' => array(
        'numeric' => array(
            'rule' => array('numeric'),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'Id' => array(
        'numeric' => array(
            'rule' => array('numeric'),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'Passenger' => array(
        'numeric' => array(
            'rule' => array('numeric'),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'Driver' => array(
        'numeric' => array(
            'rule' => array('numeric'),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'Pick_Up' => array(
        'notempty' => array(
            'rule' => array('notempty'),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'Drop_Off' => array(
        'notempty' => array(
            'rule' => array('notempty'),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
    'Modified_By' => array(
        'numeric' => array(
            'rule' => array('numeric'),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
    ),
);

}

LogCat中的Android输出是

  

12-11 01:20:17.073:I / System.out(26832):设置Reader的内容   12-11 01:20:17.133:I / System.out(26832):{“纬度”:31.4685541,“经度”:74.3374621,“国家”:“巴基斯坦”,“城市”:“拉合尔”,“Postal_Code” : “54700”, “MOBILE_NUMBER”: “03227658594”, “CURRENT_STATUS”:3, “类型”:1, “乘客”:1, “Pick_Up”: “uugfdjgsdh”, “Drop_Off”: “vjjffjjffjkkfg”, “CREATED_DATE” : “二○一三年十月十二日”, “修饰的”:假 “Total_Km”:0 “Price_Per_Km”:0 “TOTAL_PRICE”:0, “ID”:1, “驱动程序”:0, “Modified_By”:0 “状态”:0}   12-11 01:20:17.133:I / System.out(26832):我正在尝试json最终结果读取块

我在Android设备上获得状态0.Its视图为空。

0 个答案:

没有答案