我想做一個插入更新刪除網格,但當我點擊更新鏈接數據不會形成。這是我的代碼。數據不會從數據庫進入形式
<?php
public function editAction() {
$form = new Application_Form_user();
$this->view->form = $form;
if ($this->getRequest()->isPost()) {
$formData = $this->getRequest()->getPost();
if ($form->isvalid($formData)) {
$client = new Application_Model_DbTable_Client();
$firstname = $form->getvalue('firstname');
$lastname = $form->getvalue('lastname');
$email = $form->getvalue('email');
$client->updateclient($id, $firstname, $lastname, $email);
$this->_helper->redirector('index');
} else {
$this->populate($formData);
}
} else {
$id = $this->getRequest()->getparam('id');
if ($id > 0) {
$client = new Application_Model_DbTable_Client();
$clients = $client->getClient($id);
$this->populate($clients);
}
}
}
我的模型代碼: -
<?php
class Application_Model_DbTable_Client extends Zend_Db_Table_Abstract {
protected $_name = 'client';
public function getClient($id) {
global $db;
$query = $db->select()->from('client');
if ($id > 0) {
$query->where('Id=?', $id);
}
$data = $db->fetchAll($query);
return $data;
}
public function addClient() {
print_r($data);
die;
$data = array('fisrtname' => 'firstname',
'lastname' => 'lastname',
'email' => 'email');
$this->insert($data);
}
public function updateClient() {
$data = array('fisrtname' => 'firstname',
'lastname' => 'lastname',
'email' => 'email');
$this->update($data, 'Id=' . $id);
}
考慮[接受](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235)回答是否對你有幫助。 –