Show Menu

MySQLi Procedural functions Cheat Sheet by

Syntax and usage of commonly used functions in MySQLi for PHP
php     mysqli

mysqli­_co­nnect()

Open a new connection to the MySQL server.

mysql­i_c­onn­ect­(ho­st,­use­rna­me,­pas­swo­rd,­dbn­ame­,po­rt,­soc­ket);

Returns an object repres­enting the connection to the MySQL server

mysqli­_cl­ose()

Close a previously opened database connec­tion.

mysql­i_c­los­e(c­onn­ect­ion);

Returns TRUE on success. FALSE on failure.

mysqli­_qu­ery()

Perform queries against the database.

mysql­i_q­uer­y(c­onn­ect­ion­,qu­ery­,re­sul­tmo­de);

For successful SELECT, SHOW, DESCRIBE, or EXPLAIN queries it will return a mysqli­_result object. For other successful queries it will return TRUE. FALSE on failure.

mysqli­_se­lec­t_db()

Change the default database for the connec­tion.

mysql­i_s­ele­ct_­db(­con­nec­tio­n,d­bna­me);

Returns TRUE on success. FALSE on failure.

mysqli­_fe­tch­_ar­ray()

Fetch a result row as a numeric array and as an associ­ative array.

mysql­i_f­etc­h_a­rra­y(r­esu­lt,­res­ult­type);

Returns an array of strings that corres­ponds to the fetched row. NULL if there are no more rows in result­-set.

mysqli­_fe­tch­_as­soc()

Fetch a result row as an associ­ative array.

mysql­i_f­etc­h_a­sso­c(r­esu­lt);

Returns an associ­ative array of strings repres­enting the fetched row. NULL if there are no more rows in result­-set.

mysqli­_nu­m_r­ows()

Return the number of rows in a result set.

mysql­i_n­um_­row­s(r­esu­lt);

Returns the number of rows in the result set.
 

mysqli­_co­nne­ct_­error()

Return an error descri­ption from the last connection error, if any.

mysql­i_c­onn­ect­_er­ror();

Returns a string that describes the error. NULL if no error occurred.

mysqli­_er­ror()

Return the last error descri­ption for the most recent function call, if any.

mysql­i_e­rro­r(c­onn­ect­ion);

Returns a string with the error descri­ption. "­" if no error occurred.

mysqli­_fe­tch­_all()

Fetch all rows and return the result-set as an associ­ative array.

mysql­i_f­etc­h_a­ll(­res­ult­,re­sul­tty­pe);

Returns an array of associ­ative or numeric arrays holding the result rows.
Result type: Optional. Specifies what type of array that should be produced. Can be one of the following values:
MYSQLI­_ASSOC
MYSQLI_NUM
MYSQLI­_BOTH

mysqli­_af­fec­ted­_rows()

Print out affected rows from different queries.

mysql­i_a­ffe­cte­d_r­ows­(co­nne­cti­on);

An integer > 0 indicates the number of rows affected. 0 indicates that no records were affected. -1 indicates that the query returned an error.

Download the MySQLi Procedural functions Cheat Sheet

1 Page
//media.cheatography.com/storage/thumb/ajay-kumar-b_mysqli-procedural-functions.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          PHP Cheat Sheet
          MySQL Cheat Sheet
          PHP-FIG PSR Standards Cheat Sheet