### 特定のidを取得
get
public function index(){
$id = $this->request->query['id'];
$data = $this->People->get($id);
$this->set('data', $data);
}
controller
public function index(){
$data = $this->People->find("all");
$this->set('data', $data);
}
public function add(){
$entity = $this->People->newEntity();
$this->set('entity', $entity);
}
public function create(){
if($this->request->is('post')){
$data = $this->request->data['People'];
$entity = $this->People->newEntity($data);
$this->People->save($entity);
}
return $this->redirect(['action'=>'index']);
}
### Edit
<p>This is People table records.</p> <table> <thead><tr> <th>id</th><th>name</th><th>mail</th><th>age</th> </tr></thead> <?php foreach($data->toArray() as $obj): ?> <tr> <td><?=h($obj->id) ?></td> <td><a href="<?=$this->Url->build(["controller"=>"People", "action"=>"edit"]); ?>?id=<?=$obj->id ?>"><?=h($obj->name) ?></td> <td><?=h($obj->mail) ?></a></td> <td><?=h($obj->age) ?></td> </tr> <?php endforeach; ?> </table>
ほう、なるほど〜