我正在自学 php,我一直坚持表示来自一个类的数据数组。这是 Myclass.php:
class Myclass
{
private $iVar1;
private $strVar2;
public function __construct()
{
$this->initialize();
}
private function initialize()
{
$this->iVar1 = null;
$this->strVar2 = null;
}
public function getParam1()
{
return $this->iVar1;
}
public function setParam1($value)
{
$this->iVar1 = $value;
}
public function getParam2()
{
return $this->strVar2;
}
public function setParam2($value)
{
$this->strVar2 = $value;
}
}
class MyclassDAO
{
static public function load($oBD, $idObjet)
{
$aryM = MyclassDAO::getAryM($oBD, $idObjet);
return $aryM[0];
}
static public function getAryM($oBD, $omy)
{
$aryCollection = array();
$sSql = 'EXEC MYDB.dbo.SELECT_MYPROCEDURE ';
if (!is_null($omy->getParam1()))
{
$sSql .=" @param1 = '".$omy->getParam1()."',";
}
if (!is_null($omy->getParam2()))
{
$sSql .=" @param2 = '".$omy->getParam2()."',";
}
//I delete de last ,
$sSql = substr($sSql,0,strlen($sSql)-1);
while ($d = $oBD->fArray())
{
$omy = new GrupoAlumno();
$omy->setParam1($d['param1']);
$omy->setParam2($d['param2']);
$aryCollection[] = $omy;
}
return $aryCollection;
}
}
这是我的 php 文件:
require_once "Myclass.php";
$var1=1;
$var2=’Y’;
$om = new Myclass();
$om->setParam1($var1);
$om->setParam2($var2);
$omDAO = new MyclassDAO();
$ary= $omDAO->load($myObjDB, $om);
// the printing of the info here
该类返回的信息具有以下结构:
$ary: array=
0:object(Myclass)=
iVar1:long=113
strVar2:string=SOMEINFO
1: object(Myclass)=
iVar1:long=114
strVar2:string=SOMEINFO2
如何在我的 php 文件中打印它?
非常感谢!