Set a PHP object global?

前端 未结 3 1932
清酒与你
清酒与你 2020-12-11 08:41

I just started switching my project form the mysql to PDO. In my project a new PDO Object is created more or less right a the beginning of the programm.

$db         


        
3条回答
  •  星月不相逢
    2020-12-11 09:30

    You could also try using a Singleton to pass back a PDO object to you. That way you only ever have one PDO object (and one database connection) in any request which saves on memory/server resources.

提交回复
热议问题