If you use the single-state method to call a database
Source: Internet
Author: User
What if I call a database in single-state mode? If you call a database in single-state mode, the returned result set and the database connection object are included in the method. I know that the connection object is destroyed during the analysis. how can I release the returned result set, I know that you can assign a value to an array in the method and then return an array to release the result set, but sometimes you need to return the result set instead of an array. Should I release the result set if I call it? Is another method written in the class, for example, if & nbs uses the single-state mode to call the database?
If you call a database in single-state mode, the returned result set and database connection object are included in the method.
I know that the connection object is destroyed during Structure Analysis. could you tell me how to release the returned result set? I know that you can assign a value to the array in the method and then return the array to release the result set, but sometimes we need to return a result set instead of an array. Should I release the result set if I call it?
Is another method such as free () written in the class and then called outside the class? It seems that this is not easy to write. how do you deal with it. Share:
------ Solution --------------------
First, let's clarify the differences between result funding sources and result set objects.
Resource in the result set, for example, a resource number returned by mysql_query ('select... ')
A result set object (object), such as a mysqli_result object returned by mysqli_query ('select... ')
You can encapsulate the database class by yourself and make db: query return an object (such as db_result)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.