Fixed install command for multiple runs

This commit is contained in:
Dmitry Khomutov 2017-02-11 23:15:33 +07:00
commit b5759cced2
No known key found for this signature in database
GPG key ID: 7EB36C9576F9ECB9
3 changed files with 55 additions and 4 deletions

View file

@ -30,7 +30,13 @@ class ProjectGroupStoreBase extends Store
/**
* Get a single ProjectGroup by Id.
* @return null|ProjectGroup
*
* @param integer $value
* @param string $useConnection
*
* @return ProjectGroup|null
*
* @throws HttpException
*/
public function getById($value, $useConnection = 'read')
{
@ -39,7 +45,8 @@ class ProjectGroupStoreBase extends Store
}
$query = 'SELECT * FROM {{project_group}} WHERE {{id}} = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':id', $value);
if ($stmt->execute()) {
@ -50,4 +57,34 @@ class ProjectGroupStoreBase extends Store
return null;
}
/**
* Get a single ProjectGroup by title.
*
* @param integer $value
* @param string $useConnection
*
* @return ProjectGroup|null
*
* @throws HttpException
*/
public function getByTitle($value, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{project_group}} WHERE {{title}} = :title LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':title', $value);
if ($stmt->execute()) {
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
return new ProjectGroup($data);
}
}
return null;
}
}

View file

@ -68,7 +68,8 @@ class UserStoreBase extends Store
}
$query = 'SELECT * FROM {{user}} WHERE {{email}} = :email LIMIT 1';
$stmt = Database::getConnection()->prepareCommon($query);
$stmt = Database::getConnection()->prepareCommon($query);
$stmt->bindValue(':email', $value);
if ($stmt->execute()) {