توابع mysql_unbuffered_query() در PHP

تعریف و استفاده

mysql_unbuffered_query() تابع به MySQL یک درخواست SQL (بدون دریافت / ذخیره نتایج) ارسال می‌کند.

قوانین دستور زبان

mysql_unbuffered_query(query,connection)
پارامتر توضیح
query ضروری. درخواست SQLی که باید ارسال شود را تعیین می‌کند. توجه: رشته جستجو نباید با علامت ویری (؛) پایان یابد.
connection اختیاری. شناسه اتصال SQL را تعیین می‌کند. اگر تعیین نشده باشد، از اتصال باز شده قبلی استفاده می‌شود.

توضیح

mysql_unbuffered_query() به MySQL یک درخواست SQL query ارسال می‌کند، اما مانند mysql_query() to automatically retrieve and cache the result set. On one hand, this saves considerable memory when dealing with large result sets. On the other hand, you can operate on the result set immediately after obtaining the first row, without waiting for the entire SQL statement to be executed.

When using multiple database connections, you must specify the optional parameter connection.

Tips and Comments

Note:The benefits of mysql_unbuffered_query() come at a cost: The connection cannot be used on the result set returned by mysql_unbuffered_query() mysql_num_rows() and mysql_data_seek()In addition, all uncached SQL query result rows must be retrieved before sending a new SQL query to MySQL.

Example

<?php
$con = mysql_connect("localhost","mysql_user","mysql_pwd");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
// Large query
$sql = "SELECT * FROM Person";
mysql_unbuffered_query($sql,$con);
// Start processing data...
mysql_close($con);
?>