Prevent CakePHP from automatically connecting to database when instantiating model

后端 未结 2 1110
旧巷少年郎
旧巷少年郎 2021-02-11 02:40

The DBA at my company has a script that automatically kills long-running database connections and queries on our production databases. I\'ve written a CakePHP Shell application

2条回答
  •  遥遥无期
    2021-02-11 02:49

    Maybe you could use the callbacks in the AppModel for this.

    I'd guess that you could use beforeFind and beforeSafe to make a connection to the database and then use afterFind and afterSafe to kill your connection.

    As for a 'right' way of opening and closing database connections using core Cake functionality, I'm not sure but Costa's answer seems like a good (and clean!) plan.

    (1) http://book.cakephp.org/1.3/en/view/922/Database-Configuration (Link stopped working, guess you should look here now: http://book.cakephp.org/1.3/en/The-Manual/Developing-with-CakePHP/Configuration.html )

提交回复
热议问题