FUNCTION NAME |
FUNCTION DESCRIPTION |
FUNCTION SYNTAX |
FUNCTION RETURN VALUE |
mysqli::$affected_rows()
mysqli_affected_rows()
[mysqli::$affected_rows — mysqli_affected_rows – Gets the number of affected rows in a previous MySQL operation] |
This function returns the number of rows affected by the last INSERT , UPDATE , REPLACE , or DELETE query. For SELECT statements, this function works like mysqli_num_rows() . |
Object-oriented style:
$mysqli->affected_rows;
Procedural style:
mysqli_affected_rows(mysqli_link);
[mysqli_link: a link identifier returned by mysqli_connect() or mysqli_init() ; only required for the procedural style.] |
mysqli::$affected_rows() : returns an integer — an integer greater than 0 represents the number of rows affected or retrieved; 0 indicates that no records were updated for an UPDATE statement, no rows matched the WHERE clause in the query, or that no query has yet been executed; and -1 indicates that the query returned an error. If the number of affected rows exceeds PHP_INT_MAX, the number of affected rows will be returned as a string. |
mysqli::autocommit()
mysqli_autocommit()
[mysqli::autocommit — mysqli_autocommit – Turns on or off auto-committing database modifications] |
This function turns on or off auto-commit mode on queries for the database connection. The current state of autocommit can be determined by using the SQL command SELECT @@autocommit . This function does not work for non-transactional tables like MyISAM and ISAM. |
Object-oriented style:
$mysqli->autocommit(mode);
Procedural style:
mysqli_autocommit(mysqli_link, mode);
[mysqli_link: a link identifier returned by mysqli_connect() or mysqli_init() ; only required for the procedural style. mode: specifies whether to turn on auto-commit or not.] |
mysqli::autocommit() : returns TRUE on success; FALSE on failure. |
mysqli::begin_transaction()
mysqli_begin_transaction()
[mysqli::begin_transaction — mysqli_begin_transaction – Starts a transaction] |
This function begins a MySQL transaction. It requires the InnoDB engine for successful operation. |
Object-oriented style:
$mysqli->begin_transaction(flags [optional parameter, with a default value of 0], name [optional parameter]);
Procedural style:
mysqli_begin_transaction(mysqli_link, flags [optional parameter, with a default value of 0], name [optional parameter]);
[mysqli_link: a link identifier returned by mysqli_connect() or mysqli_init() ; only required for the procedural style. flags: MYSQLI_TRANS_START_READ_ONLY (MySQL 5.6+); MYSQLI_TRANS_START_READ_WRITE (MySQL 5.6+); and MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT. name: savepoint name for the transaction.] |
mysqli::begin_transaction() : returns TRUE on success; FALSE on failure. |
mysqli::change_user()
mysqli_change_user()
[mysqli::change_user — mysqli_change_user – Changes the user of the specified database connection] |
This function sets the current database and changes the user of the specified database connection. If an invalid username or password is specified – or if the user does not have sufficient permissions to access the specified database – then authorization will fail and the current user authentication will remain.
This command will always cause the database connection to behave as if it were an entirely new database connection, regardless of whether the operation was successfully completed: any active transactions are rolled back; any temporary tables are closed; and all locked tables are unlocked. |
Object-oriented style:
$mysqli->change_user(user, password, database);
Procedural style:
mysqli_change_user(mysqli_link, user, password, database);
[mysqli_link: a link identifier returned by mysqli_connect() or mysqli_init() ; only required for the procedural style. user: the MySQL user name. password: the MySQL password. database: the database to switch to. In order to simply change the user, NULL may be passed in to the function to avoid selecting a new database. The mysqli_select_db() function can then be used.] |
mysqli::change_user() : returns TRUE on success; FALSE on failure. |
mysqli::character_set_name()
mysqli_character_set_name()
[mysqli::character_set_name — mysqli_character_set_name – Returns the default character set for the database connection] |
This function returns the current character set for the database connection. |
Object-oriented style:
$mysqli->character_set_name();
Procedural style:
mysqli_character_set_name(mysqli_link);
[mysqli_link: a link identifier returned by mysqli_connect() or mysqli_init() ; only required for the procedural style.] |
mysqli::character_set_name() : returns the default character set for the current connection. |
mysqli::close()
mysqli_close()
[mysqli::close — mysqli_close – Closes a previously opened database connection] |
This function closes a previously opened database connection. Explicitly closing open database connections and freeing result sets is optional; when a PHP script finishes execution, open non-persistent MySQL connections and result sets are automatically destroyed. However, doing so is recommended, since performance-improving resources are immediately returned to PHP and MySQL. This function will not close persistent connections. |
Object-oriented style:
$mysqli->close();
Procedural style:
mysqli_close(mysqli_link);
[mysqli_link: a link identifier returned by mysqli_connect() or mysqli_init() ; only required for the procedural style.] |
mysqli::close() : returns TRUE on success; FALSE on failure. |
mysqli::commit()
mysqli_commit()
[mysqli::commit — mysqli_commit – Commits the current transaction] |
This function commits the current transaction for the specified database connection. |
Object-oriented style:
$mysqli->commit(flags [optional parameter with a default value of 0], name [optional parameter]);
Procedural style:
mysqli_commit(mysqli_link, flags [optional parameter with a default value of 0], name [optional parameter]);
[mysqli_link: a link identifier returned by mysqli_connect() or mysqli_init() ; only required for the procedural style. flags: a bitmask of MYSQLI_TRANS_COR_* constants. name: if provided, COMMIT /*name*/ is executed.] |
mysqli::commit() : returns TRUE on success; FALSE on failure. |
mysqli::$connect_errno()
mysqli_connect_errno()
[mysqli::$connect_errno — mysqli_connect_errno() – Returns the error code from last connect call] |
This function returns the last error code [‘number’/‘no’] from the last call to mysqli_connect() . The MySQL header file errmsg.h lists client error message numbers; the MySQL file mysqld_error.h lists server error message numbers. The file Docs/mysqld_error.txt in the MySQL source distribution details a complete list of error message numbers and error messages. |
Object-oriented style:
$mysqli->connect_errno;
Procedural style:
mysqli_connect_errno(); |
mysqli::$connect_errno : returns an error code value for the last call to mysqli_connect() . A return value of 0 means that no error occurred. |
mysqli::$connect_error()
mysqli_connect_error()
[mysqli::$connect_error — mysqli_connect_error – Returns a string description of the last connect error] |
This function returns the last error message string from the last call to mysqli_connect() . |
Object-oriented style:
$mysqli->connect_error;
Procedural style:
mysqli_connect_error();
[The object-oriented syntax works as of PHP 5.2.9+; use the procedural style for compatibility with earlier versions of PHP.] |
mysqli::$connect_error() : returns a string description of the error. NULL is returned if no error occurred. |
mysqli::__construct()
mysqli::connect()
mysqli_connect()
[mysqli::__construct — mysqli::connect — mysqli_connect – Open a new connection to the MySQL server] |
This function opens a connection to the MySQL server. The function parameters can be described as follows: host: either a host name or an IP address — the function assumes the local host if the NULL value or the string “localhost” is passed — pipes will be used in preference to the TCP/IP protocol where practicable — a persistent connection is created by prefixing host with p: — connections from the connection pool automatically invoke mysqli_change_user() ; username: specifies the MySQL user name; password: the MySQL server attempts to authenticate the user against those user records which have no password if password is not provided/NULL — thus, one username can be used with varying permissions, depending on if password is provided or not; database: specifies the default database to be used when performing queries, if provided; port: specifies the port number to attempt to connect to the MySQL server, if provided; and socket: specifies the socket or named pipe that should be used — how the connection is made to the MySQL server is determined by the host parameter. |
Object-oriented style – flavour one:
mysqli::__construct(host [optional parameter, with a default value of ini_get(“mysqli.default_host”)], username [optional parameter, with a default value of ini_get(“mysqli.default_user”)], password [optional parameter, with a default value of ini_get(“mysqli.default_pw”)], database [optional parameter, with a default value of “”], port [optional parameter, with a default value of ini_get(“mysqli.default_port”)], socket [optional parameter, with a default value of ini_get(“mysqli.default_socket”)]);
Object-oriented style – flavour two:
mysqli::connect(host [optional parameter, with a default value of ini_get(“mysqli.default_host”)], username [optional parameter, with a default value of ini_get(“mysqli.default_user”)], password [optional parameter, with a default value of ini_get(“mysqli.default_pw”)], database [optional parameter, with a default value of “”], port [optional parameter, with a default value of ini_get(“mysqli.default_port”)], socket [optional parameter, with a default value of ini_get(“mysqli.default_socket”)]);
Procedural style:
mysqli_connect(host [optional parameter, with a default value of ini_get(“mysqli.default_host”)], username [optional parameter, with a default value of ini_get(“mysqli.default_user”)], password [optional parameter, with a default value of ini_get(“mysqli.default_pw”)], database [optional parameter, with a default value of “”], port [optional parameter, with a default value of ini_get(“mysqli.default_port”)], socket [optional parameter, with a default value of ini_get(“mysqli.default_socket”)]); |
mysqli::__construct() : returns an object representing a connection to the MySQL server. |