Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cakephp 2.4版本未更新datsbase中的数据_Cakephp_Cakephp 2.0 - Fatal编程技术网

Cakephp 2.4版本未更新datsbase中的数据

Cakephp 2.4版本未更新datsbase中的数据,cakephp,cakephp-2.0,Cakephp,Cakephp 2.0,我正在为预订创建应用程序,该应用程序将创建取货请求,为此,我将所有字段发送给请求控制器的操作,但这不会将数据保存到数据库中。我无法理解其中的问题。该控制器的代码是 public function create() { $this->layout=''; if ($this->request->is('post')) { $this->Request->create(); $get_Count = $this->

我正在为预订创建应用程序,该应用程序将创建取货请求,为此,我将所有字段发送给请求控制器的操作,但这不会将数据保存到数据库中。我无法理解其中的问题。该控制器的代码是

 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.out26832:设置读卡器的内容 12-11 01:20:17.133:I/System.out26832:{纬度:31.4685541,经度:74.3374621,国家:巴基斯坦,城市:拉合尔,邮政编码:54700,手机号码:03227658494,当前状态:3,类型:1,乘客:1,上车:uugfdjgsdh,下车:Vjffjjjkfg,创建日期:2013年10月12日,修改:假,总公里数:0,每公里价格:0,总价格:0,司机身份证:0,修改状态:0} 12-11 01:20:17.133:I/System.out26832:我在json最终结果读取的try块中


我正在Android设备上获取状态0。其视图为空。

尝试调试$this->Request->validationErrors。保存失败的可能性很大,因为您的数据由于某种原因未验证,因此尝试打印验证错误可能会告诉您一些情况。删除多余的注释代码是个好主意。你越容易对试图帮助我的人施以援手越好:@Kai你的一句话节省了我很多时间,事实上它在created date coulmn中出现了问题。谢谢