mysqli_query single query gerenating PHP fatal error: Allowed memory size exhausted
mysqli_query single query gerenating PHP fatal error: Allowed memory size exhausted
I have a Mysql table (named "base") with 3 million records, which is composed of only 3 int(10) fields.
When I try to run this simple query $result = mysqli_query($db, 'SELECT * FROM base')
, php shows the error:
$result = mysqli_query($db, 'SELECT * FROM base')
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 10485768 bytes) in C:xampphtdocscombina.php on line 17
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 10485768 bytes) in C:xampphtdocscombina.php on line 17
I think mysqli_query should not load all the table records into memory, right?
So why the memory overflow?
I'm using XAMPP installation on Windows 10, PHP 7.2.
Here is the code:
$servername = "localhost";
$ult_elemsername = "root";
$password = "";
$dbname = "comb";
$db = mysqli_connect($servername, $ult_elemsername, $password, $dbname);
if (!$db) {
die("Falha na conexão: " . mysqli_connect_error());
}
$result = mysqli_query($db, 'SELECT * FROM base');
$result = mysqli_query($db, 'SELECT * FROM base')
I added the code now in question
– Rogério Dec
13 mins ago
There's no
fetch
though?– user3783243
12 mins ago
fetch
The error occurs precisely on the line
mysqli_query($db, 'SELECT * FROM base')
. I did not understand your question.– Rogério Dec
8 mins ago
mysqli_query($db, 'SELECT * FROM base')
You don't fetch the result object?
– user3783243
5 mins ago
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
The only code in the file is
$result = mysqli_query($db, 'SELECT * FROM base')
?– user3783243
19 mins ago