PicoDb update

This commit is contained in:
Frederic Guillot
2015-06-27 00:00:43 -04:00
parent 7a22f4c6d4
commit 1823430d13
18 changed files with 28 additions and 28 deletions

View File

@@ -65,7 +65,7 @@ abstract class Base extends \Core\Base
$this->container['logger']->debug($message); $this->container['logger']->debug($message);
} }
$this->container['logger']->debug('SQL_QUERIES={nb}', array('nb' => $this->container['db']->nb_queries)); $this->container['logger']->debug('SQL_QUERIES={nb}', array('nb' => $this->container['db']->nbQueries));
$this->container['logger']->debug('RENDERING={time}', array('time' => microtime(true) - @$_SERVER['REQUEST_TIME_FLOAT'])); $this->container['logger']->debug('RENDERING={time}', array('time' => microtime(true) - @$_SERVER['REQUEST_TIME_FLOAT']));
$this->container['logger']->debug('END_REQUEST='.$_SERVER['REQUEST_URI']); $this->container['logger']->debug('END_REQUEST='.$_SERVER['REQUEST_URI']);
} }

View File

@@ -241,7 +241,7 @@ class Action extends Base
return false; return false;
} }
$action_id = $this->db->getConnection()->getLastId(); $action_id = $this->db->getLastId();
foreach ($values['params'] as $param_name => $param_value) { foreach ($values['params'] as $param_name => $param_value) {
@@ -329,7 +329,7 @@ class Action extends Base
continue; continue;
} }
$action_id = $this->db->getConnection()->getLastId(); $action_id = $this->db->getLastId();
if (! $this->duplicateParameters($dst_project_id, $action_id, $action['params'])) { if (! $this->duplicateParameters($dst_project_id, $action_id, $action['params'])) {
$this->container['logger']->debug('Action::duplicate => unable to copy parameters for '.$action['action_name']); $this->container['logger']->debug('Action::duplicate => unable to copy parameters for '.$action['action_name']);

View File

@@ -48,7 +48,7 @@ abstract class Base extends \Core\Base
return false; return false;
} }
return (int) $db->getConnection()->getLastId(); return (int) $db->getLastId();
}); });
} }

View File

@@ -30,7 +30,7 @@ class Category extends Base
*/ */
public function exists($category_id, $project_id) public function exists($category_id, $project_id)
{ {
return $this->db->table(self::TABLE)->eq('id', $category_id)->eq('project_id', $project_id)->count() > 0; return $this->db->table(self::TABLE)->eq('id', $category_id)->eq('project_id', $project_id)->exists();
} }
/** /**

View File

@@ -64,7 +64,7 @@ class Currency extends Base
*/ */
public function create($currency, $rate) public function create($currency, $rate)
{ {
if ($this->db->table(self::TABLE)->eq('currency', $currency)->count() === 1) { if ($this->db->table(self::TABLE)->eq('currency', $currency)->exists()) {
return $this->update($currency, $rate); return $this->update($currency, $rate);
} }

View File

@@ -105,7 +105,7 @@ class File extends Base
new FileEvent(array('task_id' => $task_id, 'name' => $name)) new FileEvent(array('task_id' => $task_id, 'name' => $name))
); );
return (int) $this->db->getConnection()->getLastId(); return (int) $this->db->getLastId();
} }
return false; return false;

View File

@@ -123,7 +123,7 @@ class Link extends Base
return false; return false;
} }
$label_id = $this->db->getConnection()->getLastId(); $label_id = $this->db->getLastId();
if (! empty($opposite_label)) { if (! empty($opposite_label)) {
@@ -138,7 +138,7 @@ class Link extends Base
->table(self::TABLE) ->table(self::TABLE)
->eq('id', $label_id) ->eq('id', $label_id)
->update(array( ->update(array(
'opposite_id' => $this->db->getConnection()->getLastId() 'opposite_id' => $this->db->getLastId()
)); ));
} }

View File

@@ -111,7 +111,7 @@ class Project extends Base
*/ */
public function isPrivate($project_id) public function isPrivate($project_id)
{ {
return (bool) $this->db->table(self::TABLE)->eq('id', $project_id)->eq('is_private', 1)->count(); return $this->db->table(self::TABLE)->eq('id', $project_id)->eq('is_private', 1)->exists();
} }
/** /**
@@ -305,7 +305,7 @@ class Project extends Base
return false; return false;
} }
$project_id = $this->db->getConnection()->getLastId(); $project_id = $this->db->getLastId();
if (! $this->board->create($project_id, $this->board->getUserColumns())) { if (! $this->board->create($project_id, $this->board->getUserColumns())) {
$this->db->cancelTransaction(); $this->db->cancelTransaction();
@@ -391,7 +391,7 @@ class Project extends Base
*/ */
public function exists($project_id) public function exists($project_id)
{ {
return $this->db->table(self::TABLE)->eq('id', $project_id)->count() === 1; return $this->db->table(self::TABLE)->eq('id', $project_id)->exists();
} }
/** /**

View File

@@ -53,7 +53,7 @@ class ProjectDuplication extends Base
return 0; return 0;
} }
return $this->db->getConnection()->getLastId(); return $this->db->getLastId();
} }
/** /**

View File

@@ -39,7 +39,7 @@ class ProjectIntegration extends Base
*/ */
public function saveParameters($project_id, array $values) public function saveParameters($project_id, array $values)
{ {
if ($this->db->table(self::TABLE)->eq('project_id', $project_id)->count() === 1) { if ($this->db->table(self::TABLE)->eq('project_id', $project_id)->exists()) {
return $this->db->table(self::TABLE)->eq('project_id', $project_id)->update($values); return $this->db->table(self::TABLE)->eq('project_id', $project_id)->update($values);
} }
@@ -61,6 +61,6 @@ class ProjectIntegration extends Base
->table(self::TABLE) ->table(self::TABLE)
->eq('project_id', $project_id) ->eq('project_id', $project_id)
->eq($option, $value) ->eq($option, $value)
->count() === 1; ->exists();
} }
} }

View File

@@ -219,7 +219,7 @@ class ProjectPermission extends Base
->table(self::TABLE) ->table(self::TABLE)
->eq('project_id', $project_id) ->eq('project_id', $project_id)
->eq('user_id', $user_id) ->eq('user_id', $user_id)
->count() === 1; ->exists();
} }
/** /**
@@ -237,7 +237,7 @@ class ProjectPermission extends Base
->eq('project_id', $project_id) ->eq('project_id', $project_id)
->eq('user_id', $user_id) ->eq('user_id', $user_id)
->eq('is_owner', 1) ->eq('is_owner', 1)
->count() === 1; ->exists();
} }
/** /**
@@ -266,7 +266,7 @@ class ProjectPermission extends Base
->table(Project::TABLE) ->table(Project::TABLE)
->eq('id', $project_id) ->eq('id', $project_id)
->eq('is_everybody_allowed', 1) ->eq('is_everybody_allowed', 1)
->count() === 1; ->exists();
} }
/** /**

View File

@@ -390,7 +390,7 @@ class Subtask extends Base
$this->db->table(self::TABLE) $this->db->table(self::TABLE)
->eq('status', self::STATUS_INPROGRESS) ->eq('status', self::STATUS_INPROGRESS)
->eq('user_id', $user_id) ->eq('user_id', $user_id)
->count() === 1; ->exists();
} }
/** /**

View File

@@ -349,6 +349,6 @@ class TaskFinder extends Base
*/ */
public function exists($task_id) public function exists($task_id)
{ {
return $this->db->table(Task::TABLE)->eq('id', $task_id)->count() === 1; return $this->db->table(Task::TABLE)->eq('id', $task_id)->exists();
} }
} }

View File

@@ -133,7 +133,7 @@ class TaskLink extends Base
'link_id' => $link_id, 'link_id' => $link_id,
)); ));
$task_link_id = $this->db->getConnection()->getLastId(); $task_link_id = $this->db->getLastId();
// Create the opposite task link // Create the opposite task link
$this->db->table(self::TABLE)->insert(array( $this->db->table(self::TABLE)->insert(array(

View File

@@ -38,7 +38,7 @@ class User extends Base
*/ */
public function exists($user_id) public function exists($user_id)
{ {
return $this->db->table(self::TABLE)->eq('id', $user_id)->count() === 1; return $this->db->table(self::TABLE)->eq('id', $user_id)->exists();
} }
/** /**

View File

@@ -12,7 +12,7 @@ class DatabaseProvider implements ServiceProviderInterface
{ {
$container['db'] = $this->getInstance(); $container['db'] = $this->getInstance();
$container['db']->stopwatch = DEBUG; $container['db']->stopwatch = DEBUG;
$container['db']->log_queries = DEBUG; $container['db']->logQueries = DEBUG;
} }
/** /**

8
composer.lock generated
View File

@@ -301,12 +301,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/fguillot/picoDb.git", "url": "https://github.com/fguillot/picoDb.git",
"reference": "dd08649713c9d8330b3c5fa23220a11cb5da3e79" "reference": "e56c9d0f944bd768dc7c75e6726f7e811f114415"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/fguillot/picoDb/zipball/dd08649713c9d8330b3c5fa23220a11cb5da3e79", "url": "https://api.github.com/repos/fguillot/picoDb/zipball/e56c9d0f944bd768dc7c75e6726f7e811f114415",
"reference": "dd08649713c9d8330b3c5fa23220a11cb5da3e79", "reference": "e56c9d0f944bd768dc7c75e6726f7e811f114415",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -330,7 +330,7 @@
], ],
"description": "Minimalist database query builder", "description": "Minimalist database query builder",
"homepage": "https://github.com/fguillot/picoDb", "homepage": "https://github.com/fguillot/picoDb",
"time": "2015-06-24 21:58:15" "time": "2015-06-27 03:51:24"
}, },
{ {
"name": "fguillot/simple-validator", "name": "fguillot/simple-validator",

View File

@@ -80,7 +80,7 @@ abstract class Base extends PHPUnit_Framework_TestCase
new Stopwatch new Stopwatch
); );
$this->container['db']->log_queries = true; $this->container['db']->logQueries = true;
$this->container['logger'] = new Logger; $this->container['logger'] = new Logger;
$this->container['logger']->setLogger(new File('/dev/null')); $this->container['logger']->setLogger(new File('/dev/null'));