It is clear that a large volume of data requires a large memory of the method. For minimum remembrance use on the side of the client application on the base, you use the cadets, using mysql_fetch_array, which extracts the following result from the courseor. When using mysql_query, it buffers the result, you work with the data collector, which is processed and stored in the PHP violin, naturally with a large volume of data, the normal memory of the crypt is not enough. It's called a buffered request.Help comes the function of mysql_unbuffered_query, it does not maintain the result of memory, but moves the courser into the database, so that the memory of the crypt is not quashed. It's called a non-buffered request.In the case of mysql_query, you work with a PHP memorial cadet, and in the second case with a database cadet. Change. mysql_query ♪ mysql_unbuffered_query And it's gonna be great.I want to see that expansion of mysql is outdated and its use is not safe, at a minimum, due to the absence of a function of alignment, and support for PHP 5.5 and above, use mysqli or PDO library, the latter provides more easily targeted access to data.Unsuggested requests have advantages and disadvantages:Benefits:The result can be read sooner, waiting time is reduced;The result has no place in operational memory.Insufficient:It is not possible to know how many lines have been received;It is not possible to move to a certain result, i.e. to read data only from the beginning and on order;Other requests cannot be met until this result is closed.The non-buffed PDO request looks like:<?php
$pdo = new PDO("mysql:host=localhost;dbname=world", 'my_user', 'my_pass');
$pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
$uresult = $pdo->query("SELECT Name FROM City");
if ($uresult) {
while ($row = $uresult->fetch(PDO::FETCH_ASSOC)) {
echo $row['Name'] . PHP_EOL;
}
}
?>
Here. http://php.net/manual/ru/mysqlinfo.concepts.buffering.php information is available on the bufferiated and non-bufferiated English request.P.S If you only need an ID, choose only id, not all fields from the table.