2016-08-04 2 views
0

이것은 내 코드이므로 간단한 저장에 문제가 있습니다. 메시지는 내가이 내 테이블[cakePHP3] 실패한 저장을 디버그하는 방법

$user = $this->Users->newEntity();   
    if($this->request->is('post')) 
    {      
     $user = $this->Users->patchEntity($user, $this->request->data);  

     if($this->Users->save($user)) 
     { 
      $this->Flash->success(':)'); 
      return $this->redirect(['controller' => 'Users', 'action' => 'index']); 
     } 
     else 
     {     
      $this->Flash->error(':('); 

     } 
     debug($this->request->data);    
    } 
    $this->set(compact('user')); 

을 저장하려고 할 때 :(, 난 마이그레이션을했다. 모든 항목이 null이 될 수있는이 내 요청 데이터입니다

$table = $this->table('users'); 
    $table->addColumn('first_name','string',array('limit'=>100)) 
      ->addColumn('last_name','string',array('limit'=>100)) 
      ->addColumn('email','string',array('limit'=>100)) 
      ->addColumn('password','string') 
      ->addColumn('role','enum',array('values'=>'admin,user')) 
      ->addColumn('active','boolean') 
      ->addColumn('created','datetime') 
      ->addColumn('modified','datetime') 
      ->create(); 

[ 
'first_name' => 'wewe', 
'last_name' => 'wewe', 
'email' => '[email protected]', 
'password' => 'wewewe', 
'role' => 'admin', 
'active' => '1' 

]

당신이 나를 도왔 으면 좋겠어. 매우 좌절 했어.

EDIT : print_r을 사용하는 경우 ($ user-> errors()); 내가이 얻을 ...

Array ([firts_name] => Array ([_required] => This field is required)) 

답변

1

귀하의 오류는 데이터의 이름에 요청 데이터는

'FIRST_NAME'=> 'wewe' "

당신의 열입니다 이름은 "firts _name"의 입력 오류입니다.

나는 죽고 싶지
+0

youuuuuuuuuuuuuuuuuuuuuuuuuuuu에게 –

+0

좋은 캐치 오타 감사합니다 :) –