douhuan6065
2016-04-13 13:40
浏览 60
已采纳

CakePHP ORM ::断开数据库连接

I'm using the CakePHP ORM package inside a Gearman Worker. Package : https://packagist.org/packages/cakephp/orm

$connectionObject = ConnectionManager::get('Backend');
$usersTable = TableRegistry::get('Users', ['connection' => $connectionObject]);
$countActiveUsers = $usersTable->find()->where(['active' => 1])->count();

I'm trying to find a way to disconnect the database when a job finish to be processed because now, even if there is no job in the queue, the connection between the worker and the database remains open.

Thanks in advance!

图片转代码服务由CSDN问答提供 功能建议

我在Gearman Worker中使用CakePHP ORM包。 Package: https://packagist.org/packages/cakephp/orm

  $ connectionObject  = ConnectionManager :: get('Backend'); 
 $ usersTable = TableRegistry :: get('Users',['connection'=> $ connectionObject]); 
 $ countActiveUsers = $ usersTable-> find()  - > where(['active'=> 1]) - > count(); 
   
 
 

我正试图找到一种方法来断开连接 数据库,当一个作业完成处理,因为现在,即使队列中没有作业,工作者和数据库之间的连接仍然打开。

提前致谢!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题