From 6b325794e3998679e7444f186ada630b93e0b43a Mon Sep 17 00:00:00 2001 From: Simon Males Date: Wed, 12 Dec 2012 18:38:15 +0800 Subject: [PATCH] Re-use existing PDO object --- Console/Command/Task/CakeDjjobTask.php | 13 ++----------- Console/Command/WorkerShell.php | 13 ++----------- Controller/Component/CakeDjjobComponent.php | 11 +---------- Model/Behavior/CakeDjjobBehavior.php | 11 +---------- 4 files changed, 6 insertions(+), 42 deletions(-) diff --git a/Console/Command/Task/CakeDjjobTask.php b/Console/Command/Task/CakeDjjobTask.php index 79e34db..cf32651 100644 --- a/Console/Command/Task/CakeDjjobTask.php +++ b/Console/Command/Task/CakeDjjobTask.php @@ -44,16 +44,7 @@ function configure($config) { $connection = ConnectionManager::getDataSource($this->settings['connection']); if ($this->settings['type'] == 'mysql') { - DJJob::configure( - implode(';', array( - "{$this->settings['type']}:host={$connection->config['host']}", - "dbname={$connection->config['database']}", - "port={$connection->config['port']}", - )), array( - 'mysql_user' => $connection->config['login'], - 'mysql_pass' => $connection->config['password'] - ) - ); + DJJob::setConnection($connection->getConnection()); } else { DJJob::configure( implode(';', array( @@ -142,4 +133,4 @@ function bulkEnqueue($jobs, $queue = "default", $run_at = null) { function status($queue = "default") { return DJJob::status($queue); } -} \ No newline at end of file +} diff --git a/Console/Command/WorkerShell.php b/Console/Command/WorkerShell.php index a248522..3b59bb3 100644 --- a/Console/Command/WorkerShell.php +++ b/Console/Command/WorkerShell.php @@ -50,16 +50,7 @@ public function startup() { $connection = ConnectionManager::getDataSource($this->params['connection']); if ($this->params['type'] == 'mysql') { - DJJob::configure( - implode(';', array( - "{$this->params['type']}:host={$connection->config['host']}", - "dbname={$connection->config['database']}", - "port={$connection->config['port']}", - )), array( - 'mysql_user' => $connection->config['login'], - 'mysql_pass' => $connection->config['password'] - ) - ); + DJJob::setConnection($connection->getConnection()); } else { DJJob::configure( implode(';', array( @@ -146,4 +137,4 @@ public function getOptionParser() { )); } -} \ No newline at end of file +} diff --git a/Controller/Component/CakeDjjobComponent.php b/Controller/Component/CakeDjjobComponent.php index 9167885..0eb1026 100644 --- a/Controller/Component/CakeDjjobComponent.php +++ b/Controller/Component/CakeDjjobComponent.php @@ -44,16 +44,7 @@ public function initialize(Controller $controller) { $connection = ConnectionManager::getDataSource($this->settings['connection']); if ($this->settings['type'] == 'mysql') { - DJJob::configure( - implode(';', array( - "{$this->settings['type']}:host={$connection->config['host']}", - "dbname={$connection->config['database']}", - "port={$connection->config['port']}", - )), array( - 'mysql_user' => $connection->config['login'], - 'mysql_pass' => $connection->config['password'] - ) - ); + DJJob::setConnection($connection->getConnection()); } else { DJJob::configure( implode(';', array( diff --git a/Model/Behavior/CakeDjjobBehavior.php b/Model/Behavior/CakeDjjobBehavior.php index 056d3a8..abe65e1 100644 --- a/Model/Behavior/CakeDjjobBehavior.php +++ b/Model/Behavior/CakeDjjobBehavior.php @@ -43,16 +43,7 @@ public function setup(Model $model, $config = array()) { $connection = ConnectionManager::getDataSource($this->settings['connection']); if ($this->settings['type'] == 'mysql') { - DJJob::configure( - implode(';', array( - "{$this->settings['type']}:host={$connection->config['host']}", - "dbname={$connection->config['database']}", - "port={$connection->config['port']}", - )), array( - 'mysql_user' => $connection->config['login'], - 'mysql_pass' => $connection->config['password'] - ) - ); + DJJob::setConnection($connection->getConnection()); } else { DJJob::configure( implode(';', array(