In learning
1. Launch API support for PHP
(1) First modify the configuration file of your php.ini.
Look for the following statement:
; Extension=php_mysqli.dll
Modify it to:
Extension=php_mysqli.dll
(2) Restart the Apache/iis, you can.
(3) Description: PHP needs a separate file to support this extension library, generally in the PHP directory in the EXT directory can find php_mysqli.dll files (php <= 5.0.2 is Libmysqli.dll), of course, in the PHP configuration file should have the correct point to ext information (EXTENSION_DIR). If your PHP does not have this file, you can download the PHP5 source package. In addition, this API extension can only be used in versions above PHP5. For other specific information, please see below.
2.PHP mysqli ID
MYSQLI is the abbreviation for "MySQL, improved", which applies only to PHP 5. It can be used for MySQL 4.1.1 and later versions. The extension fully supports the authentication protocol used in MySQL 5.1, and also supports preprocessing statements and multi-statement APIs. In addition, the extension provides an advanced, object-oriented programming interface.
3. MYSQLI pre-defined classes
Mysqli
The connection between PHP and MySQL database is expressed.
constructor function
Mysqli-Constructs a new PHP mysqli object
Method
Autocommit-turn on or turn off the auto-submit database option
Change_user-the user who changed the specified database connection
Character_set_name-Returns the default character set for the database connection
Close-Closes a previously opened connection
Commit-Commit the current transaction
Connect-Opens a new connection to the MySQL database server
Debug-Perform an error-handling operation
Dump_debug_info-Get the wrong information
Get_client_info-Returns the client version
Get_host_info-Returns the type used by the connection
Get_server_info-Returns the version of the MySQL server
Get_server_version-Returns the version of the MySQL server
init-Initialize PHP mysqli object
Info-Get information about the most recently executed query
Kill-Requires the server to stop a MySQL thread
Multi_query-Execute multiple queries
More_results-check If more results exist from currently executed Multi-query
Next_result-reads next result from currently executed Multi-query
Options-set Options
Ping-pings a server connection or reconnects if there is no connection
Prepare-prepares a SQL query
Query-performs a query
Real_connect-attempts to open a connection to MySQL database server
Escape_string-escapes special characters in a string for use in a SQL statement, taking to account the current charset of the connection
Rollback-rolls back the current transaction
Select_db-selects the default database
Set_charset-sets The default client character set
Ssl_set-sets SSL Parameters
Stat-gets the current system status
Stmt_init-initializes a statement for use with Mysqli_stmt_prepare
Store_result-transfers a resultset from last query
Thread_safe-returns whether thread safety is given or not
Use_result-transfers an unbuffered resultset from last query
Property
Affected_rows-gets the number of affected rows in a previous MySQL operation
Client_info-returns the MySQL client version as a string
Client_version-returns the MySQL client version as an integer
Errno-returns the "error code for the" recent function call
Error-returns the error string for the most recent function call
Field_count-returns the number of columns for the most recent query
Host_info-returns A string representing the type of connection used
Info-retrieves information about the most recently executed query
Insert_id-returns the auto generated ID used in the last query
Protocol_version-returns the version of the MySQL protocol used
Server_info-returns A string that represents the server version number
Server_version-returns The version number of the server as an integer
Sqlstate-returns A string containing the SQLSTATE error code for the last error
Thread_id-returns the thread ID for the current connection
Warning_count-returns the number of warnings generated during execution of the previous SQL statement
4. Basic Syntax
- Php
-
- /* Connect to a MySQL server connection database server */
- $ Link = Mysqli_connect (
- ' localhost ',/* The host to connect to connection to the MySQL address */
- ' User ',/* The user to connect as connection MySQL username */
- ' Password ',/* The password to use connect mysql password */
- ' World '); /* The default database to query connects to the DB name */
-
- if (! $link) {
- printf ("Can ' t connect to MySQL Server. Errorcode:%s ", Mysqli_connect_error ());
- Exit
- }
-
- /* Send a query to the server sends a request to the servers */
- if ($result = mysqli_query($link, ' SELECT Name, Population from City ORDER by Population DESC LIMIT 5 ')) {
-
- Print ("Very Large Cities is:");
-
- /* Fetch The results of the query results */
- While ($row = mysqli_fetch_assoc($result)) {
- printf ("%s (%s)", $row [' Name '], $row [' Population ']);
- }
-
- /* Destroy The result set and free memory used for it end query
- Mysqli_free_result ($result);
- }
-
- /* Close the connection connection */
- Mysqli_close ($link);
- ?>
The solutions described above can help us easily solve the problem of PHP mysqli connection database.
http://www.bkjia.com/PHPjc/446385.html www.bkjia.com true http://www.bkjia.com/PHPjc/446385.html techarticle in learning 1. Enable PHP API support (1) First modify your php.ini configuration file. Look for the following statement:; Extension=php_mysqli.dll modify it to: Extension=php_mysqli.dll ...