MySQLi - PHP Syntax

MySQL can be used with PHP programming languages. PHP provides verious function to call mysql database query.

  • We can develop good web application using php and mysql database.
  • We can create web services used in android mobile app and other application using php and mysql database.
  • PHP MySQLi functions gives access of the MySQLi database servers.

PHP - MySQLi Functions

PHP provides mysqli database functions as below.

$link=mysqli_connect(SERVER,USERNAME,PASSWORD); - It is used to open connection with mysql server. It returns MySQL link identifier on success or false on failure.

mysqli_select_db($link,DATABASE); - It is used to select database from server.

$rs=mysqli_query($link,"MySql Query"); - This function is used to execute mysql query like select, insert, delete, update etc.

mysqli_fetch_array($rs); - This function is used to fetch records from table. It returns data in array format.

mysqli_fetch_assoc($rs); - This function is used to fetch records from table. It returns data in asscoiate array format.

mysqli_fetch_object($rs); - This function is used to fetch records from table. It returns data in object fromat.

mysqli_connect_errno(); - This function returns the error description from the last connection error if any.

mysqli_close($link); - This function is used to close database connection.

$cnt=mysqli_num_rows($rs); - This function is used to get number of records in table.

$id=mysqli_insert_id($link); - This function is used to get primary key of inserted data in table.

mysqli_affected_rows($link); - This function returns the number of affected rows in the previous SELECT, INSERT, UPDATE, REPLACE, or DELETE query.

 

 

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

86263