MySQL Improved Extension (
Mysqli
)
2312
A world full of choices to please everybody.
The object oriented interface is used for the quickstart because the reference section is organized that
way.
Mixing styles
It is possible to switch between styles at any time. Mixing both styles is not recommended for code
clarity and coding style reasons.
Example 20.79. Bad coding style
<?php
$mysqli = new mysqli("example.com", "user", "password", "database");
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: " . $mysqli->connect_error;
}
$res = mysqli_query($mysqli, "SELECT 'Possible but bad style.' AS _msg FROM DUAL");
if (!$res) {
echo "Failed to run query: (" . $mysqli->errno . ") " . $mysqli->error;
}
if ($row = $res->fetch_assoc()) {
echo $row['_msg'];
}
?>
The above example will output:
Possible but bad style.
See also
mysqli::__construct
mysqli::query
mysqli_result::fetch_assoc
$mysqli::connect_errno
$mysqli::connect_error
$mysqli::errno
$mysqli::error
The MySQLi Extension Function Summary
20.7.3.3.2. Connections
Copyright 1997-2012 the PHP Documentation Group. [2230]
The MySQL server supports the use of different transport layers for connections. Connections use
TCP/IP, Unix domain sockets or Windows named pipes.
The hostname
localhost
has a special meaning. It is bound to the use of Unix domain sockets. It is
not possible to open a TCP/IP connection using the hostname
localhost
you must use
127.0.0.1
instead.
Example 20.80. Special meaning of localhost
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...