Mariadb 简明教程
MariaDB - PHP Syntax
MariaDB 与广泛的编程语言和框架(例如 PHP、C#、JavaScript、Ruby on Rails、Django 等)合作良好。PHP 由于其简单性和历史足迹,仍然是所有可用语言中最流行的语言。本指南将重点关注与 MariaDB 合作的 PHP。
MariaDB partners well with a wide variety of programming languages and frameworks such as PHP, C#, JavaScript, Ruby on Rails, Django, and more. PHP remains the most popular of all available languages due to its simplicity and historical footprint. This guide will focus on PHP partnered with MariaDB.
PHP 提供了一组用于处理 MySQL 数据库的功能。这些功能执行诸如访问数据库或执行操作之类的任务,并且它们与 MariaDB 完全兼容。只需像调用任何其他 PHP 函数一样调用这些函数。
PHP provides a selection of functions for working with the MySQL database. These functions perform tasks like accessing it or performing operations, and they are fully compatible with MariaDB. Simply call these functions as you would call any other PHP function.
您用于 MariaDB 的 PHP 函数遵循以下格式:
The PHP functions you will use for MariaDB conform to the following format −
mysql_function(value,value,...);
函数的第二部分指定其动作。本指南中使用的两个函数如下:
The second part of the function specifies its action. Two of the functions used in this guide are as follows −
mysqli_connect($connect);
mysqli_query($connect,"SQL statement");
以下示例演示了对 MariaDB 函数的 PHP 调用的常规语法:
The following example demonstrates the general syntax of a PHP call to a MariaDB function −
<html>
<head>
<title>PHP and MariaDB</title>
</head>
<body>
<?php
$retval = mysql_function(value, [value,...]);
if( !$retval ) {
die ( "Error: Error message here" );
}
// MariaDB or PHP Statements
?>
</body>
</html>
在下一节中,我们将使用 PHP 函数检查基本的 MariaDB 任务。
In the next section, we will examine essential MariaDB tasks, using PHP functions.