function getEmpById($id){ $sql="select * from empmanage where id=$id"; $arr=$this->db_getAll($sql); $emp = new Emp(); $emp->setId($arr[0]['id']); $emp->setName($arr[0]['name']); $emp->setGrade($arr[0]['grade']); $emp->setEmail($arr[0]['email']); $emp->setSalary($arr[0]['salary']); return $emp; }
public function updateEmp($id) { $sql = "select * from emp where id={$id}"; $sqlHelper = new SqlHelper(); $arr = $sqlHelper->execute_dql2($sql); $sqlHelper->close_connect(); $emp = new Emp(); $emp->setId($arr['0']['id']); $emp->setName($arr['0']['name']); $emp->setGrade($arr['0']['grade']); $emp->setEmail($arr['0']['email']); //return $arr; return $emp; }
function getEmpById($id) { $sql = "select * from emp where id={$id}"; $sqlHelper = new SqlHelper(); $arr = $sqlHelper->execute_dql2($sql); $sqlHelper->close_connect(); //二次封装.$arr->Emp对象实例 //创建Emp对象实例 $emp = new Emp(); $emp->setId($arr[0]['id']); $emp->setName($arr[0]['name']); $emp->setGrade($arr[0]['grade']); $emp->setEmail($arr[0]['email']); return $emp; }