0
cakephp에 새로운 기능이 있습니다. 나는 필요한 모든 단계를 수행 왔지만 여전히 Articlecontroller.php에서 CakePHP의와 데이터베이스에 adduser 명령 기능의오류 : boolean에 멤버 함수 newEntity()를 호출하십시오.
코드를 데이터 저장에 문제가 : USERTABLE 모델의
public function adduser()
{
$user = $this->Users->newEntity();
if ($this->request->is('post')) {
$user = $this->Users->patchEntity($user, $this->request->getData());
// Hardcoding the user_id is temporary, and will be removed later
// when we build authentication out.
$user->user_id = 1;
if ($this->Users->save($user)) {
$this->Flash->success(__('Your article has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('Unable to add your article.'));
}
$this->set('article', $user);
}
코드 :
<?php
// src/Model/Table/ArticlesTable.php
namespace App\Model\Table;
use Cake\ORM\Table;
class UsersTable extends Table
{
public function initialize(array $config)
{
$this->addBehavior('Timestamp');
}
}