dongzuan4917 2014-05-18 10:10
浏览 35
已采纳

什么是Mysqli连接?

This is the what I can visualise at the moment:

MySQL server is running, which is an application that listens on a port (something I'm not 100% clear on at the moment).

The server parses PHP code, part of which involves sending input to the MySQL server (which is a completely separate program via specific ports (code written in the mysqli class?),

which then returns output that the mysqli class interprets? and these messages are interpreted into errors, or an established connection, or a successful query, etc?

Is this a reasonably correct view of MySQL/PHP communication?

  • 写回答

1条回答 默认 最新

  • dongyuan4790 2014-05-18 10:24
    关注

    MySQL is a program which runs persistently in the background somewhere and manages data storage. It offers an interface to the outside world via a socket connection, on which it accepts SQL queries which prompt it to store new data or return existing data. To connect to this socket and send SQL queries over it, you need to speak a specific protocol that MySQL expects; it's just technical minutiae of how exactly to talk to MySQL over that socket. mysqli is one of the PHP libraries which can speak that protocol and thereby offers PHP code a method to talk to MySQL in SQL queries, abstracting the specifics of the socket protocol away. The mysql library (now old and deprecated) and PDO can do the same thing, they just "look" different on the PHP side (i.e. their PHP code interfaces are different from mysqli).

    The (mostly) complete chain is:

    • browser speaks to web server via HTTP-over-TCP-socket
    • web server loads PHP module which loads and executes your code
    • your code instructs the PHP mysqli module to establish a socket connection to MySQL
    • your code instructs mysqli to send SQL queries over the established connection to MySQL (SQL-over-TCP-socket or SQL-over-UNIX-socket)
    • your code does whatever is does with the result, spitting out a response to the web server
    • the web server returns PHP's output to the browser over the open HTTP connection
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器