我有一个叫Person的类,有他的get和set,我想知道如何从数据层返回一个List。在C#中我使用列表,我可以返回列表,但在PHP中,我不知道如何。在PHP中的对象列表
function AllPersons()
{
try
{
$objConn = new Connection();
$conn = $objConn ->Connect();
$sql = "SELECT * FROM PERSON";
$answer= mysqli_query($cn, $sql);
if(mysqli_num_rows($answer) > 0)
{
while($row = mysqli_fetch_array($answer))
{
/*here i want to do something like in C#
List<Person>listPerson;
listPerson.add(objPerson);*/
}
}
else
{
return null;
}
}
catch (Exception $e)
{
//FB::log("nada");
}
}
你的意思是你想返回一个[数组](http://www.php.net/manual/en/language.types.array.php)? –