我已经编写了代码来搜索名字和姓氏并显示这些特定记录(如果可用)并对这些记录执行更新和删除等操作,我编写了以下代码进行搜索,请告诉我构建的正确方法是什么搜索控制器。我收到以下错误:
Message: Method "select" does not exist and was not trapped in __call()
我在控制器中编写的代码是:
public function searchAction($params)
{
$query = $this->select()
->from(
array('EMPLOYEES'),
array('FIRST_NAME','LAST_NAME','SALARY','HIREDATE')
);
$query = $this->_makeParams($query,$params);
return $this->fetchAll($query);
}
private function _makeParams($query, $params)
{
$firstname = isset($params['firstname']) ? trim($params['firstname']) : '';
$lastname = isset($params['lastname']) ? trim($params['lastname']) : '';
$salary = isset($params['salary']) ? trim($params['salary']) : '';
$hiredate= isset($params['hiredate']) ? trim($params['hiredate']) : '';
if($firstname!='')
{
$name = '%'.$this->quote($firstname).'%';//quote is my own function
$query->where("EMPLOYEES.FIRST_NAME LIKE '?'",$firstname);
}
if($lastname!='')
{
$query->where("EMPLOYEES.LAST_NAME =?",$lastname);
}
if($salary!='')
{
$query->where("EMPLOYEES.SALARY=?",$salary);
}
if($hiredate!='')
{
$query->where("EMPLOYEES.HIRE_DATE=?",$hiredate);
}
}