Home > Article > Backend Development > Relationship between PHP and MySQL
This article is prepared for those who are new to PHP. Before we prepare to embark on the road of PHP, we still need to understand the relationship between PHP and databases and MySQL. This is very important.
PHP is the back-end programming language, and MySQL is the database.
PHP and MySQL are both core members of the LAMP (Linux+Apache+MySQL+PHP) combination.
There are also many developers on Linux who use Nginx instead of Apache to provide services with PHP-FPM.
PHP has a very close relationship with MySQL. PHP has built-in the MySQL driver (mysqlnd) since 5.4. In other words, the MySQL driver It is part of the PHP backbone code. When configuring and compiling, you can directly specify mysqlnd, replacing MySQL's official libmysql:
php-src/ext/mysqlnd
--with-mysql=mysqlnd
--with-mysqli =mysqlnd
--with-pdo-mysql=mysqlnd
Compare PHP to add PostgreSQL driver:
sudo apt-get install libpq-dev
--with-pgsql=/usr/bin /pg_config
--with-pdo-pgsql=/usr/bin/pg_config
It can be seen that the PostgreSQL development library needs to be installed first.
The addition of Oracle support to PHP is also similar to PostgreSQL, and Oracle development needs to be installed first. Package (Oracle Instant Client):
Oracle Instant Client needs to be downloaded from the Oracle official website.
--with-oci8=shared,instantclient,/usr/lib/oracle/11.2/client/lib
--with -pdo-oci=shared,instantclient,/usr/lib/oracle,11.2
PHP is also quite close to another database, SQLite, because PHP has a built-in SQLite engine directly.
--with-sqlite3 Enabled by default
--with-pdo-sqlite Enabled by default
In addition, PHP has also built-in a single-process HTTP server for testing and development starting from 5.4:
php -S localhost: 8080 -t /www
Execute the above command to create an HTTP server that listens to port 8080, the website root directory is /www, and supports PHP programming and SQLite storage.
This PHP built-in server is quite lightweight and economical resources (RES memory occupies about 5MB), it is not difficult to run on an Android phone.
The relationship between PHP and MySQL is very brief to explain, but they are very useful for writing programs. You cannot do without them at all, so we will provide a large number of resource articles to answer this for you. Please pay attention to the PHP Chinese website.
Related recommendations:
PHP uses MySQL to save session, phpmysqlsession_PHP tutorial
Operation points of PHP connecting to MySQL data, phpmysql data points_PHP tutorial
The above is the detailed content of Relationship between PHP and MySQL. For more information, please follow other related articles on the PHP Chinese website!