我知道如何关闭在PHP MySQL连接有没有办法在cakephp中关闭mysql连接?
<?php
$con=mysql_connect("localhost","user","password","dbname");
// ....some PHP code...
mysql_close($con);
?>
但如何关闭MySQL连接CakePHP中
在此先感谢
我知道如何关闭在PHP MySQL连接有没有办法在cakephp中关闭mysql连接?
<?php
$con=mysql_connect("localhost","user","password","dbname");
// ....some PHP code...
mysql_close($con);
?>
但如何关闭MySQL连接CakePHP中
在此先感谢
试试这个..
$this->ModelName->getDatasource()->disconnect();
我在哪里写这行? – psanjib 2015-02-12 05:55:49
在您想要与数据库断开连接的模型中...另请参阅此接受的答案http://stackoverflow.com/questions/10098844/prevent-cakephp-from-automatically-connecting-to-database-when-instantiating- MOD – 2015-02-12 05:58:24
HTTP:/ /stackoverflow.com/questions/5118519/cakephp-reconnect-to-db – Shin 2015-02-12 05:55:43
只是一个说明,最好让服务器处理连接,除非需要明确指出TLY。当连接太多时,根据我以前的经验,可能会出现db错误。 – Gogol 2015-02-12 05:58:07