This is a legacy code. the original programmer directly instantiates the database instance $ dbnewdb () in the configuration file. If this code is normally used to include requireinclude, in his judgment, $ GLOBALS [& #039; db & #039;] is used for determination. Because there are a lot of files, and now I want to reuse... this is a legacy code, the original programmer directly instantiate the database instance in the configuration file
$ Db = new db ();
If this type of code is normal, use require/include to include the code without any worries, and use $ GLOBALS ['DB'] to judge the code.
Because there are a lot of files, I want to reuse some models now. because of the inclusion relationship, I have to try them one by one and then include them. I want to make them automatically loaded, so I used composer to automatically load them, the file $ GLOBALS ['DB'] automatically loaded using composer is empty. I do not need this global parameter at ordinary times.
I have solved this problem by myself, that is, change $ db = new db () to $ GLOBALS ['DB'], and then assign values explicitly.
I don't understand why $ db that is manually included exists. $ db automatically loaded using composer will not be deleted. thank you for your guidance.
Reply content:
This is a legacy code. the original programmer instantiated the database instance directly in the configuration file.
$ Db = new db ();
If this type of code is normal, use require/include to include the code without any worries, and use $ GLOBALS ['DB'] to judge the code.
Because there are a lot of files, I want to reuse some models now. because of the inclusion relationship, I have to try them one by one and then include them. I want to make them automatically loaded, so I used composer to automatically load them, the file $ GLOBALS ['DB'] automatically loaded using composer is empty. I do not need this global parameter at ordinary times.
I have solved this problem by myself, that is, change $ db = new db () to $ GLOBALS ['DB'], and then assign values explicitly.
I don't understand why $ db that is manually included exists. $ db automatically loaded using composer will not be deleted. thank you for your guidance.