Mysqli 简明教程
MySQLi - PHP Syntax
MySQL 可与 PERL、C、C++、JAVA 和 PHP 等各种编程语言完美结合使用。在这些语言中,PHP 因其 Web 应用程序开发功能而最受欢迎。
MySQL works very well in combination of various programming languages like PERL, C, C++, JAVA and PHP. Out of these languages, PHP is the most popular one because of its web application development capabilities.
本教程着重于在 PHP 环境中使用 MySQL。如果您对带有 PERL 的 MySQL 感兴趣,那么您可以考虑阅读 PERL 教程。
This tutorial focuses heavily on using MySQL in a PHP environment. If you are interested in MySQL with PERL, then you can consider reading the PERL Tutorial.
PHP 提供了各种功能来访问 MySQL 数据库并在 MySQL 数据库中操作数据记录。您需要像调用任何其他 PHP 函数一样调用 PHP 函数。
PHP provides various functions to access the MySQL database and to manipulate the data records inside the MySQL database. You would require to call the PHP functions in the same way you call any other PHP function.
用于 MySQL 的 PHP 函数采用以下常规格式:
The PHP functions for use with MySQL have the following general format −
mysqli function(value,value,...);
函数名的第二部分特定于函数,通常是一个描述函数执行操作的单词。以下是我们将在本教程中使用的两个函数:
The second part of the function name is specific to the function, usually a word that describes what the function does. The following are two of the functions, which we will use in our tutorial −
$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
mysqli→query(,"SQL statement");
以下示例显示 PHP 调用任何 MySQL 函数的通用语法。
The following example shows a generic syntax of PHP to call any MySQL function.
<html>
<head>
<title>PHP with MySQL</title>
</head>
<body>
<?php
$retval = mysqli - > <i>function</i>(value, [value,...]);
if( !$retval ) {
die ( "Error: a related error message" );
}
// Otherwise MySQL or PHP Statements
?>
</body>
</html>
从下一章开始,我们将看到所有重要的 MySQL 功能以及 PHP。
Starting from the next chapter, we will see all the important MySQL functionality along with PHP.