我有daoHistorial.php:
require "transferDao/daoTransferHistorial.php";
require "bdconnection.php";
class daoHistorial{
public function sqlSelect($tarea){
$aObjects=array();
$dbconn = new DBconnection();
$db = $dbconn->bdConnection();
$stmt = $db->prepare("SELECT t1.tar_id, t1.rea_seccion, t1.rea_porcentaje, t1.rea_descripcion, t1.hrs_tarea, t1.tar_fechtermino
FROM act_registtarea t1
inner join act_tarea t2
ON t1.tar_id = t2.tar_id
where t2.tar_nombre = '$tarea'");
$stmt->execute();
$stmt->setFetchMode(PDO::FETCH_ASSOC);
$result = $stmt->fetchAll();
foreach ($result as $row) {
$aTransfer = new daoTransferHistorial();
$aTransfer->setPorcentaje($row['rea_porcentaje']);
$aTransfer->setDescripcion($row['rea_descripcion']);
$aTransfer->setFechaTermino($row['tar_fechtermino']);
$aTransfer->setSeccion($row['rea_seccion']);
$aTransfer->setHora($row['hrs_tarea']);
$aObjects[]=$aTransfer;
}
print_r($aObjects);
return $aObjects;
}
}
?>
我有controllerHistorial.php:
require "dao/daoHistorial.php";
class HistorialTareas {
public function getHistorial() {
$aTransfer = new daoHistorial();
foreach($aTransfer->sqlSelect() as $sKey=>$oValue){
$list[] = array('porcentaje' => $oValue->getPorcentaje(),
'descripcion' => $oValue->getDescripcion(),
'fecha_termino' => $oValue->getFechaTermino(),
'seccion' =>$oValue->getSeccion(),
'hora' =>$oValue->getHora()
);
}
print_r($list);
return $list;
}
}
?>
这里:foreach($aTransfer-> sqlSelect()as $sKey => $oValue){我有一个问题,因为缺少参数
sqlSelect()
我需要使用`daoHistorial.php中的sqlSelect($tarea).
我知道我需要在公共函数getHistorial($tarea)中传递参数
但我需要这个:
public function getHistorial() {
$aTransfer = new daoHistorial();
foreach($aTransfer->sqlSelect($tarea) as $sKey=>$oValue){
因为在我需要getHistorial()之后没有参数.