对此可能有一个非常简单的解释,但是我已经让这段代码工作了几个月,现在突然间今天它不起作用了。
我从表中检索所有行。我有和对象,它是我从中选择的表的实体模型。当我从关联结果数组中读取行时,我使用“$this->propertyName”存储每个属性,然后将每个对象推送到一个数组中。在我以对象数组结束之前,现在我以重复相同对象的数组结束。这是一个代码片段:
$mdSelectALL_sql="SELECT * FROM member_data";
$mdSelectALL=mysql_query($mdSelectALL_sql,$mdConn);
if(!$mdSelectALL){
die('Error: ' . mysql_error());
}
else{
echo "RETURNING ALL MEMBER DATA RECORDS!!!<br>";
//store all records into array
while($row=mysql_fetch_array($mdSelectALL))
{
$this->mdId=$row['md_id'];
$this->mdFname=$row['md_fname'];
$this->mdLname=$row['md_lname'];
$this->mdEmail=$row['md_email'];
$this->mdTwitter=$row['md_twitter'];
$this->mdFacebook=$row['md_facebook'];
$this->mdMyspace=$row['md_myspace'];
$this->mdPhoneNumber=$row['md_phonenumber'];
$this->mdNotes=$row['md_notes'];
//store records in array
array_push($mdArray,$this);
}//end while
// print_r($mdArray); prints the array and each element is the last record encountered in the SQL retrieval
return $mdArray;
}//end else
对于每个属性,我的 getter 和 setter 看起来像这样:
function get_mdId(){
return $this->mdId;
}
function set_mdId($id){
$this->mdId=$id;
}
和建议或想法?
-TU