1. Database Connection Functions
These functions are used for connecting to MySQL databases.
mysqli_connect()— Opens a new connection to the MySQL server (procedural).mysqli_connect_errno()— Returns the error code from the last connection attempt.mysqli_connect_error()— Returns a description of the last connection error.mysqli_select_db()— Selects the database to use (procedural).mysqli_get_client_version()— Returns the MySQL client version.mysqli_get_host_info()— Returns the current MySQL host information.mysqli_get_proto_info()— Returns the MySQL protocol version.
2. Query Execution Functions
These functions execute SQL queries and handle the results.
mysqli_query()— Performs a query on the database (procedural).mysqli_multi_query()— Performs multiple SQL queries at once (procedural).mysqli_query()— Executes a single query (returns a result set ortrueon success).mysqli_prepare()— Prepares an SQL statement for execution (object-oriented).mysqli_stmt_prepare()— Prepares a statement for execution (procedural).mysqli_stmt_execute()— Executes a prepared statement (procedural).mysqli_stmt_bind_param()— Binds parameters to a prepared statement (procedural).mysqli_stmt_get_result()— Retrieves the result set from a prepared statement (procedural).
3. Fetching and Retrieving Results
These functions are used to fetch or retrieve data from query results.
mysqli_fetch_assoc()— Fetches a result row as an associative array.mysqli_fetch_row()— Fetches a result row as a numeric array.mysqli_fetch_object()— Fetches a result row as an object.mysqli_fetch_all()— Fetches all result rows as an array (available in MySQLi).mysqli_fetch_lengths()— Returns the length of the fields in the result set.mysqli_num_rows()— Returns the number of rows in the result set.mysqli_num_fields()— Returns the number of fields in a result set.mysqli_fetch_field()— Retrieves information about a field in the result set.mysqli_fetch_fields()— Retrieves an array of field information.
4. Prepared Statement Functions
These functions work specifically with prepared statements, which are used to prevent SQL injection.
mysqli_prepare()— Prepares a SQL statement for execution.mysqli_stmt_bind_param()— Binds variables to a prepared statement as parameters.mysqli_stmt_bind_result()— Binds variables to store results of a prepared statement.mysqli_stmt_execute()— Executes a prepared statement.mysqli_stmt_fetch()— Fetches the results of a prepared statement.mysqli_stmt_get_result()— Retrieves the result set from a prepared statement.
5. Data Insertion, Update, and Deletion
These functions are used for manipulating data in MySQL.
mysqli_insert_id()— Returns the auto-increment ID generated by the lastINSERTquery.mysqli_affected_rows()— Returns the number of affected rows by the last query.mysqli_query()— Executes anINSERT,UPDATE, orDELETEquery (returnstrueon success).mysqli_commit()— Commits the current transaction (used withmysqli_begin_transaction()).mysqli_rollback()— Rolls back the current transaction (used withmysqli_begin_transaction()).mysqli_autocommit()— Enables or disables autocommit mode.
6. Error Handling Functions
These functions are used for handling errors when working with MySQL.
mysqli_error()— Returns the last error message for the most recent MySQL operation.mysqli_errno()— Returns the error code for the most recent MySQL operation.mysqli_sqlstate()— Returns the SQLSTATE error code for the most recent MySQL operation.mysqli_warning_count()— Returns the number of warnings from the last query.
7. Transaction Management
These functions help manage database transactions.
mysqli_begin_transaction()— Starts a transaction (MySQL 5.5 and higher).mysqli_commit()— Commits the current transaction.mysqli_rollback()— Rolls back the current transaction.mysqli_autocommit()— Turns autocommit mode on or off.mysqli_set_charset()— Sets the default character set for the connection.
8. Database and Table Management Functions
These functions are used to manage databases, tables, and other schema elements.
mysqli_select_db()— Selects a database to work with.mysqli_create_db()— Creates a new database.mysqli_drop_db()— Drops an existing database.mysqli_query()— Executes a query, likeCREATE TABLE,DROP TABLE, etc.mysqli_list_tables()— Lists all tables in the selected database.mysqli_list_fields()— Lists fields (columns) of a table.mysqli_show_tables()— Shows the tables in the selected database.
9. Connection and Session Functions
These functions help manage the MySQL server connection.
mysqli_ping()— Pings the server to check if the connection is still alive.mysqli_close()— Closes the MySQL connection.mysqli_get_client_version()— Returns the MySQL client version.mysqli_get_host_info()— Returns information about the current host connection.mysqli_get_proto_info()— Returns the protocol version used to communicate with MySQL.mysqli_get_server_version()— Returns the MySQL server version.
10. Result Set and Field Functions
These functions are used to handle and manipulate the result set.
mysqli_free_result()— Frees the memory associated with a result.mysqli_field_seek()— Seeks to a specified field in a result set.mysqli_fetch_field()— Retrieves a single field information from the result.mysqli_fetch_fields()— Retrieves an array of field information.mysqli_data_seek()— Seeks to a specified row in a result set.
11. MySQLi and PDO (Object-Oriented Functions)
Both MySQLi and PDO provide object-oriented approaches to working with MySQL databases.
MySQLi Object-Oriented
$mysqli->connect()— Establishes a connection to the database.$mysqli->query()— Executes a query on the database.$mysqli->prepare()— Prepares an SQL statement for execution.$mysqli->bind_param()— Binds variables to a prepared statement.$mysqli->execute()— Executes a prepared statement.$mysqli->fetch_assoc()— Fetches a result row as an associative array.
PDO (PHP Data Objects)
$pdo->connect()— Establishes a connection to the database (via a DSN).$pdo->prepare()— Prepares an SQL statement for execution.$pdo->execute()— Executes a prepared statement.$pdo->fetch()— Fetches the next row from a result set.$pdo->exec()— Executes a query and returns the number of affected rows.
12. Miscellaneous Functions
These are additional functions related to MySQL operations.
mysqli_get_client_version()— Returns the client version of MySQL.mysqli_get_server_version()— Returns the server version of MySQL.mysqli_get_charset()— Returns the current character set of the MySQL connection.
No hay comentarios:
Publicar un comentario