我有这段代码:
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . '/framework/classes/DBConnection.php');
define('DB_NAME', 'thename');
define('DB_HOST', 'thehost.com');
define('DB_USER', 'user');
define('DB_PASSWORD', 'pwd');
// Connect to database
function db_connect() {
return DBConnection::GetConnection();
}
function getMeta($conn) {
$sql = "SELECT order_ref FROM orders LIMIT 0,1";
$stmt = $conn->prepare($sql);
$stmt->execute();
$stmt->bind_result($ref);
$stmt->fetch();
$stmt->close();
return $ref;
}
function getMeta2($conn, $page) {
$sql = "SELECT meta FROM pages_meta WHERE pageid = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param('s', $page);
$stmt->execute();
$stmt->bind_result($meta);
$stmt->fetch();
$stmt->close();
return $meta;
}
$conn = db_connect();
?>
</head>
<body>
<h1>Hello World</h1>
<?php echo getMeta($conn); ?>
<br>
<?php echo getMeta2($conn, "homepage"); ?>
</body>
</html>
<?php
$conn->close();
?>
输出:
Hello World
1407324725
Fatal error: Allowed memory size of 209715200 bytes exhausted (tried to allocate 4294967296 bytes) in /home/rnsalarm/co2supermarket.co.uk/test.php on line 41
咦???!运行此SQL时出现内存不足异常:
SELECT meta FROM pages_meta WHERE pageid =?
该表只有15行,即使这样它也有索引。有什么想法发生了什么?网站的其余部分工作正常,只是这一个查询它抛出一个摇摆。增加一些神秘感;如果我在我的本地开发计算机上运行,连接到同一个数据库,只有当它上传到服务器时我才能解决这个问题。这很奇怪。就像我说的那样,网站的其余部分工作得非常好。
有什么想法在这里发生了什么?
答案 0 :(得分:2)