How to call database in php

藏色散人
Release: 2023-03-06 17:52:02
Original
7172 people have browsed it

How PHP calls the database: first connect to the database through the "mysqli_connect" method; then execute the command "show databaces"; and finally send the command to the MySQL server.

How to call database in php

Recommended: "PHP Video Tutorial"

1. Three ways to call the database Method:

Command (cmd), language call (PHP, GO), third-party software.

Command mode:

How to call database in php

Language call:

<?php
//链接数据库
$link = mysqli_connect(&#39;localhost&#39;, &#39;root&#39;, &#39;&#39;);
//SQL命令的准备
$sql = &#39;show databaces&#39;;
//讲话命令发送到MySQL服务器
$res = mysqli_query($link, $sql);
var_dump($res);
?>
Copy after login

Third-party software:

How to call database in php

2. Operation process

  1. Link database
  2. Set encoding (Communication encoding)
  3. Write SQL statements
  4. Send SQL statements to MySQL server
  5. MuSQL server receives SQL statements and parses them
  6. Parsing completed Finally, return the result to the calling program

    How to call database in php

The above is the detailed content of How to call database in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!