我收到这个错误。我使用类文件、函数文件和视图文件。致命错误:允许的内存已耗尽
public function adminSearchFullName($admin_firstname,$admin_lastname){
$adminsearchresultsfullname = array();
try {
$db = database::databaseConnect();
$stmt = $db->prepare('SELECT * FROM personalinfo WHERE firstname like ? AND lastname like ? AND deleted = 0');
$stmt->execute(array('%' . $admin_firstname . '%', '%' . $admin_lastname . '%'));
$adminsearchresultsfullname = $stmt->fetchAll(PDO::FETCH_OBJ);
if($stmt->rowCount() < 1){
$adminsearchresultsfullname = null;
}
$db = null;
}
catch (PDOException $e){
$adminsearchresultsfullname = null;
}
return $adminsearchresultsfullname;
}
我的功能如下所示:
function adminSearchFullName($admin_firstname,$admin_lastname){
return $adminsearchresultsfullname = adminSearchFullName($admin_firstname,$admin_lastname);
}
最后我的视图页面如下所示:
if(!empty ($admin_firstname) && !empty($admin_lastname)){
//Query and display contact details based on first and last names.
$adminsearchresultsfullname = adminSearchFullName($admin_firstname,$admin_lastname);
if ($adminsearchresultsfullname != null){
?>
<a href="index.php">Home</a> | <a href="adduser.php">Add User</a> | <a href="viewusers.php">View Users</a> |<a href="addcontact.php">Add Contact</a> | <a href="viewcontacts.php">View Contacts</a> | <a href="searchcontact.php">Search Contact</a><br /><hr />
<p>Click on the name to see details of the contact.</p>
<table cellpadding="5">
<tr>
<td>
<b>Search result</b>
</td>
</tr>
<?php
foreach($adminsearchresultsfullname as $key => $adminfoundfullname){
$admin_id_fullname = $adminfoundfullname->id;
$admin_found_fullname_firstname = $adminfoundfullname->firstname;
$admin_found_fullname_lastname = $adminfoundfullname->lastname;
?>
<tr>
<td>
<a href="contactdetails.php?id=<?php echo $admin_id_fullname; ?>"><?php echo $admin_found_fullname_firstname . ' ' . $admin_found_fullname_lastname; ?></a>
</td>
</tr>
<?php
}?>
</table>
<?php }
}else{
echo 'No record found. Please <a href="searchcontact.php"> return</a> and try a different name.';
}
其余的以及仅查找名字和姓氏的所有其他功能都可以正常工作。