Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between mysqli_query and mysqli_real_query

Tags:

php

mysqli

What is the difference between mysqli::query and mysqli::real_query?

OR

What is the difference between mysqli_query and mysqli_real_query?

like image 974
itsazzad Avatar asked Nov 20 '12 09:11

itsazzad


People also ask

What is mysqli_query () used for?

The query() / mysqli_query() function performs a query against a database.

What is the output of mysqli_query?

Mysqli_connect doesn't target the table and mysqli_query doesn't output anything.

How many parameters does the mysqli_query () function accept?

PHP uses mysqli query() or mysql_query() function to create or delete a MySQL database. This function takes two parameters and returns TRUE on success or FALSE on failure.

What does query return in PHP?

Return Values ¶ Returns false on failure. For successful queries which produce a result set, such as SELECT, SHOW, DESCRIBE or EXPLAIN , mysqli_query() will return a mysqli_result object. For other successful queries, mysqli_query() will return true .


2 Answers

mysqli::query will return a result if there is any.

mysql::real_query will return true on success or false if not

You could have seen this in the php doc:

  • query,
  • real_query.
like image 173
Thomas Avatar answered Oct 02 '22 16:10

Thomas


Look at the documentation of mysqli_query():

Functionally, using this function is identical to calling mysqli_real_query() followed either by mysqli_use_result() or mysqli_store_result().

From what I understand real_query actually executes the query, and use/store_result initiates the process of retrieving a result set for the query. query() does both.

like image 25
Bgi Avatar answered Oct 02 '22 18:10

Bgi