Fixing issues related to LIMIT in Base Store files.
This commit is contained in:
parent
9379da1393
commit
d481140ea2
5 changed files with 63 additions and 182 deletions
|
|
@ -20,24 +20,11 @@ class BuildMetaStoreBase extends Store
|
|||
protected $modelName = '\PHPCI\Model\BuildMeta';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Get a BuildMeta by primary key.
|
||||
* @param mixed $value Primary key.
|
||||
* @param string $useConnection Connection to use (read / write)
|
||||
* @return \PHPCI\Model\BuildMeta|null
|
||||
*/
|
||||
public function getByPrimaryKey($value, $useConnection = 'read')
|
||||
{
|
||||
return $this->getById($value, $useConnection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a BuildMeta by Id.
|
||||
* @param mixed $value.
|
||||
* @param string $useConnection Connection to use (read / write)
|
||||
* @throws \b8\Exception\HttpException
|
||||
* @return \PHPCI\Model\BuildMeta|null;
|
||||
*/
|
||||
public function getById($value, $useConnection = 'read')
|
||||
{
|
||||
if (is_null($value)) {
|
||||
|
|
@ -57,31 +44,17 @@ class BuildMetaStoreBase extends Store
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of BuildMeta by ProjectId.
|
||||
* @param mixed $value.
|
||||
* @param int $limit
|
||||
* @param string $useConnection Connection to use (read / write)
|
||||
* @throws \b8\Exception\HttpException
|
||||
* @return \PHPCI\Model\BuildMeta[]
|
||||
*/
|
||||
public function getByProjectId($value, $limit = null, $useConnection = 'read')
|
||||
public function getByProjectId($value, $limit = 1000, $useConnection = 'read')
|
||||
{
|
||||
if (is_null($value)) {
|
||||
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
|
||||
}
|
||||
|
||||
$add = '';
|
||||
|
||||
if ($limit) {
|
||||
$add .= ' LIMIT ' . $limit;
|
||||
}
|
||||
|
||||
$count = null;
|
||||
|
||||
$query = 'SELECT * FROM `build_meta` WHERE `project_id` = :project_id' . $add;
|
||||
$query = 'SELECT * FROM `build_meta` WHERE `project_id` = :project_id LIMIT :limit';
|
||||
$stmt = Database::getConnection($useConnection)->prepare($query);
|
||||
$stmt->bindValue(':project_id', $value);
|
||||
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
$res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
|
@ -91,37 +64,25 @@ class BuildMetaStoreBase extends Store
|
|||
};
|
||||
$rtn = array_map($map, $res);
|
||||
|
||||
$count = count($rtn);
|
||||
|
||||
return array('items' => $rtn, 'count' => $count);
|
||||
} else {
|
||||
return array('items' => array(), 'count' => 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of BuildMeta by BuildId.
|
||||
* @param mixed $value.
|
||||
* @param int $limit
|
||||
* @param string $useConnection Connection to use (read / write)
|
||||
* @throws \b8\Exception\HttpException
|
||||
* @return \PHPCI\Model\BuildMeta[]
|
||||
*/
|
||||
public function getByBuildId($value, $limit = null, $useConnection = 'read')
|
||||
public function getByBuildId($value, $limit = 1000, $useConnection = 'read')
|
||||
{
|
||||
if (is_null($value)) {
|
||||
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
|
||||
}
|
||||
|
||||
$add = '';
|
||||
|
||||
if ($limit) {
|
||||
$add .= ' LIMIT ' . $limit;
|
||||
}
|
||||
|
||||
$count = null;
|
||||
|
||||
$query = 'SELECT * FROM `build_meta` WHERE `build_id` = :build_id' . $add;
|
||||
$query = 'SELECT * FROM `build_meta` WHERE `build_id` = :build_id LIMIT :limit';
|
||||
$stmt = Database::getConnection($useConnection)->prepare($query);
|
||||
$stmt->bindValue(':build_id', $value);
|
||||
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
$res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
|
@ -131,6 +92,8 @@ class BuildMetaStoreBase extends Store
|
|||
};
|
||||
$rtn = array_map($map, $res);
|
||||
|
||||
$count = count($rtn);
|
||||
|
||||
return array('items' => $rtn, 'count' => $count);
|
||||
} else {
|
||||
return array('items' => array(), 'count' => 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue