我显然处于深渊。我没有掌握 Doctrine ModelClass 和 Model Table Class 扩展基本模型的好处
例如
class StaffStaff extends Base_StaffStaff
{
public function getStaffInformation($id_staff_staff){ // == getInformationsByStaff()
$query = Doctrine_Query::create()
->from("StaffStaff s")
->innerJoin('s.StaffContract c')
->where("s.id_staff_staff = ?", $id_staff_staff);
$result = $query->execute();
return $result;
}
}
并在控制器中
StaffController{
public function readAction() {
$id = $this->getRequest()->getParam("id_staff_staff");
// Get information about a staff
$model = new StaffStaff();
$q = $model->getStaffInformation($id);
$this->view->data = $q[0];
/**
*
* Why do you have to say $q[0] ?
* Is there no better way of doing it?
* How can we access the properties from other tables contained inside the BaseClass extended by the ModelClass
*
*/
}
模型:
/**
* Base_StaffStaff
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @property integer $id_staff_staff
* @property integer $fk_id_staff_individual
* @property integer $fk_id_staff_team
* @property integer $fk_id_staff_function
*
*/