MySQLi - Real Query
语法
bool mysqli_real_query ( mysqli $link , string $query )
定义和用法
它用于执行 SQL 查询。
示例
试试下面的例子 −
<?php $servername = "localhost:3306"; $username = "root"; $password = ""; $dbname = "TUTORIALS"; $conn = new mysqli($servername, $username, $password, $dbname); if (!$conn->real_connect($servername, $username, $password, $dbname)) { die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error()); } echo 'Success... ' . mysqli_get_host_info($conn) . " "; $result = $conn->real_query("Select * From tutorials_auto"); if($conn->connect_errno){ echo $conn->connect_error; } return $result == true; $conn->close(); ?>
上述代码的示例输出应该是这样的 −
Success... localhost:3306 via TCP/IP