这里需要一些代码的帮助
我有一系列Classe notas,我使用此代码从数据库中获取信息:
$this->notas = new Collection();
$this->carregaArray();
public function carregaArray(){
$link = mysql_connect('localhost:3307', 'root', 'usbw');
$l = mysql_select_db('estagio', $link);
$sql = "Select * From notas";
$result = mysql_query($sql,$link);
while($row = mysql_fetch_assoc($result)){
$this->notas->addItem($row);
}
}
我试图在此方法上使用$ this-> notas:
public function procurarNota($idAluno,$idElemento){
if(!($this->notas->isEmpty())){
foreach($this->notas->getAll() as $nota){
for ($i = 0; $i <= $this->notas->getLength(); $i++){
if($this->notas->getItem($i)->getIdAluno() && $this->notas->getItem($i)->getIdComp() == $idElemento){
return $nota;
}
}
}
}
return 0;
}
但它给了我这个错误:
Call to a member function getIdAluno() on a non-object in D:\8.5\root\classes\UC.php on line 709
我做错了什么?
干杯