donglu9978 2013-08-22 07:33
浏览 26

mysql(i)_query和mysql(i)_fetch_ *的内部工作原理

I wonder how mysql_query/mysqli_query and mysql_fetch_*/mysqli_fetch_* functions really work. Where is result of mysql_query call stored? Is it MySQL server or PHP client? When the transmission of data occurs?

  • 写回答

1条回答 默认 最新

  • dongtaochan0777 2013-08-22 08:02
    关注

    It's a cooperation between PHP and the MySQL server. mysql*_query sends a query to the server, which prompts it to sift through its data and assemble a result set. This result set now needs to be transferred over to PHP, one row at a time.

    By default, mysql*_query uses a buffered query, which means it's transferring the data little by little over to PHP as soon as it can. When calling mysql*_fetch*, you read a row of this data one by one. You can also use unbuffered queries, e.g. using mysql_unbuffered_query. This does not transfer data in the background, it only does so when you explicitly call one of the *fetch* functions. This uses less memory on the PHP side, but is slower and in turn requires the SQL server to hold onto the data longer than it would have otherwise.

    评论

报告相同问题?

悬赏问题

  • ¥15 对于知识的学以致用的解释
  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败