Adding migrations functionality to PHPCI using Phinx

This commit is contained in:
Dan Cryer 2014-05-13 15:15:06 +00:00
commit d63a029b74
10 changed files with 608 additions and 90 deletions

View file

@ -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)) {