Why do we need to destroy so many objects when connecting to the database? it seems that after connecting to the database, we need to destroy the connection, destroy the result set, and destroy the object handle. why?
Reply to discussion (solution)
Php programs do not reside in the memory. they are lost when used up and cannot be reused.
Therefore, the system resources it occupies should be released.
However, php has a built-in garbage collection mechanism. if you do not release it, it will release it for you.
Php does not need to be manually destroyed, but developing a good programming habit is the most important thing!
Php programs do not reside in the memory. they are lost when used up and cannot be reused.
Therefore, the system resources it occupies should be released.
However, php has a built-in garbage collection mechanism. if you do not release it, it will release it for you.
Even if the memory does not reside, that is, the memory is no longer used up. what should we do to release it? Isn't that an option?
Because databases are system resources (not php resources) that are not released, they cannot be used by others.