PHP mysql_unbuffered_query() ການສະຫຼຸບຫຼັງຄາວິວັດສະດີ

ການອະທິບາຍ ແລະ ການນໍາໃຊ້

mysql_unbuffered_query() ການສະຫຼຸບຫຼັງຄາວິວັດສະດີທີ່ສົ່ງຄຳຖາມ SQL (ບໍ່ໄດ້ຮັບ / ບັນທຶກຜົນ).

ຂໍ້ບັນຍາ

mysql_unbuffered_query(query,connection)
ປະເພດ ການອະທິບາຍ
query ຕ້ອງການ. ກຳນົດຄຳຖາມ SQL ທີ່ຈະສົ່ງ. ຄວາມເຫັນ: ຄຳຖາມບໍ່ຄວນຈົບດ້ວຍສີ່ສານ.
connection ຄວາມອິດສະຫຼະ. ກຳນົດອັນດັບການເຊື່ອມຕໍ່ SQL. ຖ້າບໍ່ກຳນົດ, ຈະໃຊ້ການເຊື່ອມຕໍ່ທີ່ເປີດກ່ອນ.

ການອະທິບາຍ

mysql_unbuffered_query() ສົ່ງຄຳຖາມ SQL ສູນມັນສີນລະບາຍ query ບໍ່ໄດ້ mysql_query() to automatically retrieve and cache the result set. On the one hand, this saves a considerable amount of memory when dealing with large result sets. On the other hand, it is possible to 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, it is necessary to specify the optional parameter connection.

Tips and Comments

Note:The benefit of mysql_unbuffered_query() has a cost: it is not possible to use mysql_num_rows() and mysql_data_seek()In addition, before sending a new SQL query to MySQL, it is necessary to retrieve all the result rows generated by all uncached SQL queries.

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);
?>