PHP Lifecycle problem

A rookie problem, which is a controller of ThinkPHP, calls other methods to print $this- > accounts is [],
whether to render index or not, the life cycle of this controller instance is over. When routing access to other methods, the instance will be created again, and the database needs to be called again

.
class Index extends Controller {
    private accounts = []; 

    public function index() {
        // 1. 
        $this->accounts = model("Account")->getAccounts();    //  $this->accounts

        return $this->fetch("", [
            "list" => $this->accounts,
        ]);
    }


    public function select($id) {
        dump($this->accounts);    //    index  
    }
}
May.08,2022

main question

the life cycle of this controller instance has ended after rendering index
After

executes fetch , the controller instance finishes its work and ends its life cycle as the request completes. In tp5, each request generates an instance. The first request and the second request belong to different instances

PHP variable life cycle

for most PHP server (FPM,Apache), each PHP request is independent of each other. Variable assignment / assignment is active during compilation and execution, and finally destroys
part of the memory-resident server (swoole) when the request is closed, which is actually equivalent to executing an PHP request (executing a PHP script). Variables can exist all the time, but an instance is generated for each request in implementation, and the request is destroyed at the end of the request

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e48602-439e4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e48602-439e4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?