2
我收到此錯誤。我使用了一個類文件,函數文件,然後是視圖文件。致命錯誤:讓內存耗盡PHP OOP PDO致命錯誤:允許的內存耗盡
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.';
}
的休息和所有其他職能要麼只是名字和姓氏工作罰款。
看起來像你的內存限制,嘗試設置ini_set('memory_limit','500M'); – shapeshifter 2013-02-20 02:41:59
對不起,發現我的問題: function adminSearchFullName($ admin_firstname,$ admin_lastname){ return $ adminsearchresultsfullname = contacts :: adminSearchFullName($ admin_firstname,$ admin_lastname); } – Willem 2013-02-20 02:45:09