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 孟德尔随机化怎样画共定位分析图
  • ¥18 模拟电路问题解答有偿速度
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址
  • ¥15 elmos524.33 eeprom的读写问题