Properti dan Fungsi MySQLi


Seperti halnya MySQL API, MySQLi memiliki beragam properti & fungsi yang dapat digunakan untuk mengakses database. Berikut beragam properti & fungsi MySQLi yang dapat Anda gunakan. Tersedia dalam 2 metode yaitu dengan metode object oriented (OOP) dan prosedural.

Metode OOP

Metode Prosedural

Keterangan

MySQLi Class
Properti :
$mysqli->affected_rows mysqli_affected_rows() Mengambil jumlah baris dari perintah sebelumnya
$mysqli->client_info mysqli_get_client_info() Mengembalikan nilai versi MySQL kedalam string
$mysqli->client_version mysqli_get_client_version() Mengembalikan nilai versi MySQL ke dalam integer
$mysqli->connect_errno mysqli_connect_errno() Mengembalikan data kesalahan pada koneksi sebelumnya
$mysqli->connect_error mysqli_connect_error() Mengembalikan informasi kegagalan koneksi
$mysqli->errno mysqli_errno() Mengembalikan informasi kegagalan pada saat melakukan pemanggilan fungsi sebelumnya
$mysqli->error mysqli_error() Mengembalikan informasi kegagalan pada koneksi sebelumnya
$mysqli->field_count mysqli_field_count() Menentukan jumlah field pada sebuah tabel
$mysqli->host_info mysqli_get_host_info() Mengambil data informasi host dari koneksi
$mysqli->protocol_version mysqli_get_proto_info() Menampilkan protokol yang digunakan oleh MySQL
$mysqli->server_info mysqli_get_server_info() Menampilkan informasi server
$mysqli->server_version mysqli_get_server_version() Menampilkan informasi server
$mysqli->info mysqli_info() Mendapatkan informasi dari proses query sebelumnya, misal insert, update dan delete data
$mysqli->insert_id mysqli_insert_id() Mengembalikan id generate pada proses terakhir query yang terakhir
$mysqli->sqlstate mysqli_sqlstate() Mengembalikan kesalahan SQLSTATE pada operasi SQL sebelumnya
$mysqli->warning_count mysqli_warning_count() Mengembalikan jumlah kesalahan dari proses query sebelumnya
Methods
mysqli->autocommit() mysqli_autocommit() Turns on or off auto-committing database modifications
mysqli->change_user() mysqli_change_user() Changes the user of the specified database connection
mysqli->character_set_name(), mysqli->client_encoding mysqli_character_set_name() Returns the default character set for the database connection
mysqli->close() mysqli_close() Closes a previously opened database connection
mysqli->commit() mysqli_commit() Commits the current transaction
mysqli->__construct() mysqli_connect() Open a new connection to the MySQL server [Note: static (i.e. class) method]
mysqli->debug() mysqli_debug() Performs debugging operations
mysqli->dump_debug_info() mysqli_dump_debug_info() Dump debugging information into the log
mysqli->get_charset() mysqli_get_charset() Returns a character set object
mysqli->get_connection_stats() mysqli_get_connection_stats() Returns client connection statistics. Available only with mysqlnd.
mysqli->get_client_info() mysqli_get_client_info() Returns the MySQL client version as a string
mysqli->get_client_stats() mysqli_get_client_stats() Returns client per-process statistics. Available only with mysqlnd.
mysqli->get_cache_stats() mysqli_get_cache_stats() Returns client Zval cache statistics. Available only with mysqlnd.
mysqli->get_server_info() mysqli_get_server_info() NOT DOCUMENTED
mysqli->get_warnings() mysqli_get_warnings() NOT DOCUMENTED
mysqli->init() mysqli_init() Initializes MySQLi and returns a resource for use with mysqli_real_connect. [Not called on an object, as it returns a $mysqli object.]
mysqli->kill() mysqli_kill() Asks the server to kill a MySQL thread
mysqli->more_results() mysqli_more_results() Check if there are any more query results from a multi query
mysqli->multi_query() mysqli_multi_query() Performs a query on the database
mysqli->next_result() mysqli_next_result() Prepare next result from multi_query
mysqli->options() mysqli_options() Set options
mysqli->ping() mysqli_ping() Pings a server connection, or tries to reconnect if the connection has gone down
mysqli->prepare() mysqli_prepare() Prepare an SQL statement for execution
mysqli->query() mysqli_query() Performs a query on the database
mysqli->real_connect() mysqli_real_connect() Opens a connection to a mysql server
mysqli->real_escape_string(), mysqli->escape_string() mysqli_real_escape_string() Escapes special characters in a string for use in an SQL statement, taking into account the current charset of the connection
mysqli->real_query() mysqli_real_query() Execute an SQL query
mysqli->refresh() mysqli_refresh() Flushes tables or caches, or resets the replication server information
mysqli->rollback() mysqli_rollback() Rolls back current transaction
mysqli->select_db() mysqli_select_db() Selects the default database for database queries
mysqli->set_charset() mysqli_set_charset() Sets the default client character set
mysqli->set_local_infile_default() mysqli_set_local_infile_default() Unsets user defined handler for load local infile command
mysqli->set_local_infile_handler() mysqli_set_local_infile_handler() Set callback function for LOAD DATA LOCAL INFILE command
mysqli->ssl_set() mysqli_ssl_set() Used for establishing secure connections using SSL
mysqli->stat() mysqli_stat() Gets the current system status
mysqli->stmt_init() mysqli_stmt_init() Initializes a statement and returns an object for use with mysqli_stmt_prepare
mysqli->store_result() mysqli_store_result() Transfers a result set from the last query
mysqli->thread_id() mysqli_thread_id() Returns the thread ID for the current connection
mysqli->thread_safe() mysqli_thread_safe() Returns whether thread safety is given or not
mysqli->use_result() mysqli_use_result() Initiate a result set retrieval