在我的模型中,我具有以下功能
protected $_users ='users';
public function getbyid($user_id)
{
$select = $this->_db
->select()
->from($this->_users)
->where('users.user_id =?', $user_id);
$result = $this->_db->fetchRow($select)->toArray();
return $result;
}
当它被调用时,它返回致命错误:
Call to a member function toArray() on a non-object
谁能指出我做错的方向。
谢谢。Zend_Debug::dump($this->_db->fetchRow($select)) 的输出;
array(11) {
["user_id"] => string(1) "1"
["role"] => string(13) "administrator"
["email"] => string(18) "bjh497@hotmail.com"
["password"] => string(40) "62bb49da919f0d349ed2cbbec559d7ed649dd238"
["created"] => string(19) "2013-05-09 07:34:00"
["modified"] => NULL
["status"] => string(6) "active"
["salt"] => string(40) "ce8d96d579d389e783f95b3772785783ea1a9854"
["lastlogin"] => NULL
["first_name"] => string(3) "Bob"
["last_name"] => string(5) "Smith"
}
尝试使用结果在控制器中填充表单,如下所示
$userdetails = new Account_Model_User;
$userdetails->getbyid($user->user_id);
$userdetails = $userdetails;
$form = new Account_Form_Profile;
$form->populate($userdetails);