Fixed excessive BuildMeta inserts.
This commit is contained in:
parent
cd6bfa5942
commit
c6ae043750
3 changed files with 48 additions and 19 deletions
|
|
@ -50,7 +50,7 @@ class BuildMetaStore extends Store
|
|||
public function getById($id, $useConnection = 'read')
|
||||
{
|
||||
if (is_null($id)) {
|
||||
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
|
||||
throw new HttpException('id passed to ' . __FUNCTION__ . ' cannot be null.');
|
||||
}
|
||||
|
||||
$query = 'SELECT * FROM {{build_meta}} WHERE {{id}} = :id LIMIT 1';
|
||||
|
|
@ -66,6 +66,38 @@ class BuildMetaStore extends Store
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $buildId
|
||||
* @param string $key
|
||||
*
|
||||
* @return null|BuildMeta
|
||||
*
|
||||
* @throws HttpException
|
||||
*/
|
||||
public function getByKey($buildId, $key)
|
||||
{
|
||||
if (is_null($buildId)) {
|
||||
throw new HttpException('buildId passed to ' . __FUNCTION__ . ' cannot be null.');
|
||||
}
|
||||
|
||||
if (!$key) {
|
||||
throw new HttpException('key passed to ' . __FUNCTION__ . ' cannot be empty.');
|
||||
}
|
||||
|
||||
$query = 'SELECT * FROM {{build_meta}} WHERE {{build_id}} = :build_id AND {{meta_key}} = :meta_key LIMIT 1';
|
||||
$stmt = Database::getConnection()->prepareCommon($query);
|
||||
$stmt->bindValue(':build_id', $buildId);
|
||||
$stmt->bindValue(':meta_key', $key);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
return new BuildMeta($data);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get multiple BuildMeta by BuildId.
|
||||
*
|
||||
|
|
@ -83,7 +115,6 @@ class BuildMetaStore extends Store
|
|||
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
|
||||
}
|
||||
|
||||
|
||||
$query = 'SELECT * FROM {{build_meta}} WHERE {{build_id}} = :build_id LIMIT :limit';
|
||||
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
|
||||
$stmt->bindValue(':build_id', $buildId);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue