Skip to content
This repository has been archived by the owner on Mar 4, 2019. It is now read-only.

Commit

Permalink
Re-use existing PDO object
Browse files Browse the repository at this point in the history
  • Loading branch information
sime committed Dec 12, 2012
1 parent c3a9692 commit 6b32579
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 42 deletions.
13 changes: 2 additions & 11 deletions Console/Command/Task/CakeDjjobTask.php
Expand Up @@ -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(
Expand Down Expand Up @@ -142,4 +133,4 @@ function bulkEnqueue($jobs, $queue = "default", $run_at = null) {
function status($queue = "default") {
return DJJob::status($queue);
}
}
}
13 changes: 2 additions & 11 deletions Console/Command/WorkerShell.php
Expand Up @@ -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(
Expand Down Expand Up @@ -146,4 +137,4 @@ public function getOptionParser() {
));
}

}
}
11 changes: 1 addition & 10 deletions Controller/Component/CakeDjjobComponent.php
Expand Up @@ -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(
Expand Down
11 changes: 1 addition & 10 deletions Model/Behavior/CakeDjjobBehavior.php
Expand Up @@ -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(
Expand Down

0 comments on commit 6b32579

Please sign in to comment.