


The difference between PHP's mysqli_query parameters MYSQLI_STORE_RESULT and MYSQLI_USE_RESULT
This article mainly introduces the difference between PHP's mysqli_query parameters MYSQLI_STORE_RESULT and MYSQLI_USE_RESULT. This article gives 5 differences between these two parameters. Friends in need can refer to it
Although nosql has become popular, I feel that sql is still mainstream
When I was browsing php manul today, I found that mysqli query can pass an interesting parameter
@<span style="color: #008080;">mysqli_query</span>(<span style="color: #800080;">$this</span>->sql,<span style="color: #800080;">$SQL</span>,(<span style="color: #800080;">$method</span> ? <span style="color: #008080;">MYSQLI_USE_RESULT</span> : <span style="color: #008080;">MYSQLI_STORE_RESULT</span>));
These two parameters are explained in the php manul like this.
Either the <span style="color: #008080;">constant</span> <span style="color: #008080;">MYSQLI_USE_RESULT</span> or <span style="color: #008080;">MYSQLI_STORE_RESULT</span> depending on the desired behavior. By <span style="color: #0000ff;">default</span>, <span style="color: #008080;">MYSQLI_STORE_RESULT</span> is used.
If nothing is passed, the default is MYSQLI_STORE_RESULT.
Someone said this on phpmanul: If we have to retrieve large amount of data we use MYSQLI_USE_RESULT
In fact, the difference between these two parameters is still very big.
(1) The difference is in retrieving the rows of the result set from the server.
(2) MYSQLI_USE_RESULT starts the query, but does not actually fetch any rows
(3) MYSQLI_STORE_RESULT retrieves all rows immediately
(4) MYSQLI_STORE_RESULT When the result set is retrieved from the server, the rows are extracted and memory is allocated for them, Stored in the client, subsequent calls to mysqli_fetch_array() will never return an error because it only removes the rows from the data structure that already holds the result set. The return of NULL by mysqli_fetch_array() always indicates that the end of the result set has been reached.
(5) MYSQLI_USE_RESULT itself does not retrieve any rows, but only starts a row-by-row retrieval, which means that it must be completed by calling mysqli_fetch_array() on each row. That being the case, although under normal circumstances, mysqli_fetch_array() returning NULL still indicates that the end of the result set has been reached, it may also indicate that an error occurred while communicating with the server.
Summary
Compared with MYSQLI_USE_RESULT, MYSQLI_STORE_RESULT has higher memory and processing requirements. Because the entire result set is maintained on the client, the cost of memory allocation and creation of data structures is very huge. If you want to retrieve multiple rows at one time, you can use MYSQLI_USE_RESULT .
MYSQLI_USE_RESULT has lower memory requirements because only enough space is allocated for a single row processed each time. This is faster because there is no need to create complex data structures for the result set. MYSQLI_USE_RESULT, on the other hand, places a greater load on the server, which must retain rows in the result set until the client seems suitable to retrieve all rows.
Reference reading: http://www.manongjc.com/article/1195.html

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.