Adding migrations functionality to PHPCI using Phinx
This commit is contained in:
parent
a62307250f
commit
d63a029b74
10 changed files with 608 additions and 90 deletions
|
|
@ -44,6 +44,38 @@ class BuildMetaStoreBase extends Store
|
|||
return null;
|
||||
}
|
||||
|
||||
public function getByProjectId($value, $limit = null, $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;
|
||||
$stmt = Database::getConnection($useConnection)->prepare($query);
|
||||
$stmt->bindValue(':project_id', $value);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
$res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
||||
$map = function ($item) {
|
||||
return new BuildMeta($item);
|
||||
};
|
||||
$rtn = array_map($map, $res);
|
||||
|
||||
return array('items' => $rtn, 'count' => $count);
|
||||
} else {
|
||||
return array('items' => array(), 'count' => 0);
|
||||
}
|
||||
}
|
||||
|
||||
public function getByBuildId($value, $limit = null, $useConnection = 'read')
|
||||
{
|
||||
if (is_null($value)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue