Notice: Undefined variable: entryMessage in /var/www/Employee/application/models/EmployeeMapper.php on line 34 Fatal error: Call to a member function setEmployeeId() on a non-object in /var/www/Employee/application/models/EmployeeMapper.php on line 34
这是我得到的错误我试图显示输入的字段,我检查了数据库并且字段正在保存,我发布了Employee Mapper。请检查代码并告诉解决方案,提前谢谢
class Application_Model_EmployeeMapper
{
protected $_dbTable;
public function setDbTable($dbTable)
{
if (is_string($dbTable)) {
$dbTable = new $dbTable();
}
if (!$dbTable instanceof Zend_Db_Table_Abstract) {
throw new Exception('Invalid table data gateway provided');
}
$this->_dbTable = $dbTable;
return $this;
}
public function getDbTable()
{
if (null === $this->_dbTable) {
$this->setDbTable('Application_Model_DbTable_Employee');
}
return $this->_dbTable;
}
public function fetchAll()
{
$table = $this->getDbTable();
$resultSet = $table->fetchAll($table->select()->order('EMPLOYEE_ID'));
$entries = array();
foreach ($resultSet as $row) {
$entry = new Application_Model_Employee();
$entryMessage->setEmployeeId($this->$row->EMPLOYEE_ID)
->setFirstName($row->FIRST_NAME)
->setLastName($row->LAST_NAME)
->setEmail($row->EMAIL)
->setPhoneNumber($row->PHONE_NUMBER)
->setHireDate($row->HIRE_DATE)
->setJobId($row->JOB_ID)
->setSalary($row->SALARY);
$entries[] = $entry;
}
return $entries;
}
public function save(Application_Model_Employee $employee)
{
$data = array(
'EMAIL' => $employee->getEmail(),
'FIRST_NAME' => $employee->getFirstName(),
'LAST_NAME' => $employee->getLastName(),
'PHONE_NUMBER' => $employee->getPhoneNumber(),
'HIRE_DATE' => $employee->getHireDate(),
'JOB_ID' => $employee->getJobId(),
'SALARY' => $employee->getSalary(),
);
答案 0 :(得分:0)
您收到的错误非常清楚,您应该始终阅读并尝试理解您获得的错误消息,它为您提供了解决大多数常见问题的方法。所以总是养成阅读和理解你得到的错误信息的习惯。这里,
Notice: Undefined variable: entryMessage in /var/www/Employee/application/models/EmployeeMapper.php on line 34
注意说,未定义的变量;这意味着您的变量$entryMessage
未定义。你得到的错误的第二部分是:
Fatal error: Call to a member function setEmployeeId() on a non-object in /var/www/Employee/application/models/EmployeeMapper.php on line 34
是非常明显的,因为你试图从setEmployeeId()
调用$entryMessage
函数但尚未定义,但你假设它是一个对象并将其用作对象。
我假设您使用的$entryMessage
应该是$entry
这些非常简单,实际上并不适合在SO中提问。
再次,我对你的建议是,