Home >Backend Development >PHP Problem >How to call database in php

How to call database in php

藏色散人
藏色散人Original
2020-10-16 10:17:167225browse

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);
?>

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!

Statement:
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