Merge pull request #342 from corpsee/database-yml

Added database-based yml build config #2
This commit is contained in:
Dan Cryer 2014-04-16 09:44:13 +01:00
commit 0a8b7cd35b
13 changed files with 710 additions and 793 deletions

View file

@ -323,6 +323,14 @@ class ProjectController extends \PHPCI\Controller
$field->setRows(6);
$form->addField($field);
$field = new Form\Element\TextArea('build_config');
$field->setRequired(false);
$field->setLabel('PHPCI build config for this project (instead phpci.yml in the project repository)');
$field->setClass('form-control');
$field->setContainerClass('form-group');
$field->setRows(6);
$form->addField($field);
$field = new Form\Element\Submit();
$field->setValue('Save Project');
$field->setContainerClass('form-group');

View file

@ -3,7 +3,6 @@
/**
* Build base model for table: build
*/
namespace PHPCI\Model\Base;
use PHPCI\Model;
@ -15,336 +14,323 @@ use b8\Store\Factory;
class BuildBase extends Model
{
/**
* @var array
*/
* @var array
*/
public static $sleepable = array();
/**
* @var string
*/
* @var string
*/
protected $tableName = 'build';
/**
* @var string
*/
* @var string
*/
protected $modelName = 'Build';
/**
* @var array
*/
* @var array
*/
protected $data = array(
'id' => null,
'project_id' => null,
'commit_id' => null,
'status' => null,
'log' => null,
'branch' => null,
'created' => null,
'started' => null,
'finished' => null,
'plugins' => null,
'id' => null,
'project_id' => null,
'commit_id' => null,
'status' => null,
'log' => null,
'branch' => null,
'created' => null,
'started' => null,
'finished' => null,
'plugins' => null,
'committer_email' => null,
'commit_message' => null,
'commit_message' => null,
);
/**
* @var array
*/
* @var array
*/
protected $getters = array(
// Direct property getters:
'id' => 'getId',
'project_id' => 'getProjectId',
'commit_id' => 'getCommitId',
'status' => 'getStatus',
'log' => 'getLog',
'branch' => 'getBranch',
'created' => 'getCreated',
'started' => 'getStarted',
'finished' => 'getFinished',
'plugins' => 'getPlugins',
'id' => 'getId',
'project_id' => 'getProjectId',
'commit_id' => 'getCommitId',
'status' => 'getStatus',
'log' => 'getLog',
'branch' => 'getBranch',
'created' => 'getCreated',
'started' => 'getStarted',
'finished' => 'getFinished',
'plugins' => 'getPlugins',
'committer_email' => 'getCommitterEmail',
'commit_message' => 'getCommitMessage',
'commit_message' => 'getCommitMessage',
// Foreign key getters:
'Project' => 'getProject',
'Project' => 'getProject',
);
/**
* @var array
*/
* @var array
*/
protected $setters = array(
// Direct property setters:
'id' => 'setId',
'project_id' => 'setProjectId',
'commit_id' => 'setCommitId',
'status' => 'setStatus',
'log' => 'setLog',
'branch' => 'setBranch',
'created' => 'setCreated',
'started' => 'setStarted',
'finished' => 'setFinished',
'plugins' => 'setPlugins',
'id' => 'setId',
'project_id' => 'setProjectId',
'commit_id' => 'setCommitId',
'status' => 'setStatus',
'log' => 'setLog',
'branch' => 'setBranch',
'created' => 'setCreated',
'started' => 'setStarted',
'finished' => 'setFinished',
'plugins' => 'setPlugins',
'committer_email' => 'setCommitterEmail',
'commit_message' => 'setCommitMessage',
'commit_message' => 'setCommitMessage',
// Foreign key setters:
'Project' => 'setProject',
'Project' => 'setProject',
);
/**
* @var array
*/
* @var array
*/
public $columns = array(
'id' => array(
'type' => 'int',
'length' => 11,
'primary_key' => true,
'id' => array(
'type' => 'int',
'length' => 11,
'primary_key' => true,
'auto_increment' => true,
'default' => null,
),
'project_id' => array(
'type' => 'int',
'length' => 11,
'default' => null,
),
'project_id' => array(
'type' => 'int',
'length' => 11,
'default' => null,
),
'commit_id' => array(
'type' => 'varchar',
'length' => 50,
'commit_id' => array(
'type' => 'varchar',
'length' => 50,
'nullable' => true,
'default' => null,
),
'status' => array(
'type' => 'tinyint',
'length' => 4,
'default' => null,
),
'status' => array(
'type' => 'tinyint',
'length' => 4,
'default' => null,
),
'log' => array(
'type' => 'longtext',
'log' => array(
'type' => 'longtext',
'nullable' => true,
'default' => null,
'default' => null,
),
'branch' => array(
'type' => 'varchar',
'length' => 50,
'branch' => array(
'type' => 'varchar',
'length' => 50,
'default' => 'master',
),
'created' => array(
'type' => 'datetime',
'created' => array(
'type' => 'datetime',
'nullable' => true,
'default' => null,
'default' => null,
),
'started' => array(
'type' => 'datetime',
'started' => array(
'type' => 'datetime',
'nullable' => true,
'default' => null,
'default' => null,
),
'finished' => array(
'type' => 'datetime',
'finished' => array(
'type' => 'datetime',
'nullable' => true,
'default' => null,
'default' => null,
),
'plugins' => array(
'type' => 'text',
'plugins' => array(
'type' => 'text',
'nullable' => true,
'default' => null,
'default' => null,
),
'committer_email' => array(
'type' => 'varchar',
'length' => 512,
'type' => 'varchar',
'length' => 512,
'nullable' => true,
'default' => null,
'default' => null,
),
'commit_message' => array(
'type' => 'text',
'commit_message' => array(
'type' => 'text',
'nullable' => true,
'default' => null,
'default' => null,
),
);
/**
* @var array
*/
* @var array
*/
public $indexes = array(
'PRIMARY' => array('unique' => true, 'columns' => 'id'),
'project_id' => array('columns' => 'project_id'),
'idx_status' => array('columns' => 'status'),
'PRIMARY' => array('unique' => true, 'columns' => 'id'),
'project_id' => array('columns' => 'project_id'),
'idx_status' => array('columns' => 'status'),
);
/**
* @var array
*/
* @var array
*/
public $foreignKeys = array(
'build_ibfk_1' => array(
'local_col' => 'project_id',
'update' => 'CASCADE',
'delete' => 'CASCADE',
'table' => 'project',
'col' => 'id'
),
'build_ibfk_1' => array(
'local_col' => 'project_id',
'update' => 'CASCADE',
'delete' => 'CASCADE',
'table' => 'project',
'col' => 'id'
),
);
/**
* Get the value of Id / id.
*
* @return int
*/
* Get the value of Id / id.
*
* @return int
*/
public function getId()
{
$rtn = $this->data['id'];
$rtn = $this->data['id'];
return $rtn;
}
/**
* Get the value of ProjectId / project_id.
*
* @return int
*/
* Get the value of ProjectId / project_id.
*
* @return int
*/
public function getProjectId()
{
$rtn = $this->data['project_id'];
$rtn = $this->data['project_id'];
return $rtn;
}
/**
* Get the value of CommitId / commit_id.
*
* @return string
*/
* Get the value of CommitId / commit_id.
*
* @return string
*/
public function getCommitId()
{
$rtn = $this->data['commit_id'];
$rtn = $this->data['commit_id'];
return $rtn;
}
/**
* Get the value of Status / status.
*
* @return int
*/
* Get the value of Status / status.
*
* @return int
*/
public function getStatus()
{
$rtn = $this->data['status'];
$rtn = $this->data['status'];
return $rtn;
}
/**
* Get the value of Log / log.
*
* @return string
*/
* Get the value of Log / log.
*
* @return string
*/
public function getLog()
{
$rtn = $this->data['log'];
$rtn = $this->data['log'];
return $rtn;
}
/**
* Get the value of Branch / branch.
*
* @return string
*/
* Get the value of Branch / branch.
*
* @return string
*/
public function getBranch()
{
$rtn = $this->data['branch'];
$rtn = $this->data['branch'];
return $rtn;
}
/**
* Get the value of Created / created.
*
* @return \DateTime
*/
* Get the value of Created / created.
*
* @return \DateTime
*/
public function getCreated()
{
$rtn = $this->data['created'];
$rtn = $this->data['created'];
if (!empty($rtn)) {
$rtn = new \DateTime($rtn);
$rtn = new \DateTime($rtn);
}
return $rtn;
}
/**
* Get the value of Started / started.
*
* @return \DateTime
*/
* Get the value of Started / started.
*
* @return \DateTime
*/
public function getStarted()
{
$rtn = $this->data['started'];
$rtn = $this->data['started'];
if (!empty($rtn)) {
$rtn = new \DateTime($rtn);
$rtn = new \DateTime($rtn);
}
return $rtn;
}
/**
* Get the value of Finished / finished.
*
* @return \DateTime
*/
* Get the value of Finished / finished.
*
* @return \DateTime
*/
public function getFinished()
{
$rtn = $this->data['finished'];
$rtn = $this->data['finished'];
if (!empty($rtn)) {
$rtn = new \DateTime($rtn);
$rtn = new \DateTime($rtn);
}
return $rtn;
}
/**
* Get the value of Plugins / plugins.
*
* @return string
*/
* Get the value of Plugins / plugins.
*
* @return string
*/
public function getPlugins()
{
$rtn = $this->data['plugins'];
$rtn = $this->data['plugins'];
return $rtn;
}
/**
* Get the value of CommitterEmail / committer_email.
*
* @return string
*/
* Get the value of CommitterEmail / committer_email.
*
* @return string
*/
public function getCommitterEmail()
{
$rtn = $this->data['committer_email'];
$rtn = $this->data['committer_email'];
return $rtn;
}
/**
* Get the value of CommitMessage / commit_message.
*
* @return string
*/
* Get the value of CommitMessage / commit_message.
*
* @return string
*/
public function getCommitMessage()
{
$rtn = $this->data['commit_message'];
$rtn = $this->data['commit_message'];
return $rtn;
}
/**
* Set the value of Id / id.
*
* Must not be null.
* @param $value int
*/
* Set the value of Id / id.
*
* Must not be null.
*
* @param $value int
*/
public function setId($value)
{
$this->_validateNotNull('Id', $value);
@ -353,18 +339,17 @@ class BuildBase extends Model
if ($this->data['id'] === $value) {
return;
}
$this->data['id'] = $value;
$this->_setModified('id');
}
/**
* Set the value of ProjectId / project_id.
*
* Must not be null.
* @param $value int
*/
* Set the value of ProjectId / project_id.
*
* Must not be null.
*
* @param $value int
*/
public function setProjectId($value)
{
$this->_validateNotNull('ProjectId', $value);
@ -373,17 +358,15 @@ class BuildBase extends Model
if ($this->data['project_id'] === $value) {
return;
}
$this->data['project_id'] = $value;
$this->_setModified('project_id');
}
/**
* Set the value of CommitId / commit_id.
*
* @param $value string
*/
* Set the value of CommitId / commit_id.
*
* @param $value string
*/
public function setCommitId($value)
{
$this->_validateString('CommitId', $value);
@ -391,18 +374,17 @@ class BuildBase extends Model
if ($this->data['commit_id'] === $value) {
return;
}
$this->data['commit_id'] = $value;
$this->_setModified('commit_id');
}
/**
* Set the value of Status / status.
*
* Must not be null.
* @param $value int
*/
* Set the value of Status / status.
*
* Must not be null.
*
* @param $value int
*/
public function setStatus($value)
{
$this->_validateNotNull('Status', $value);
@ -411,17 +393,15 @@ class BuildBase extends Model
if ($this->data['status'] === $value) {
return;
}
$this->data['status'] = $value;
$this->_setModified('status');
}
/**
* Set the value of Log / log.
*
* @param $value string
*/
* Set the value of Log / log.
*
* @param $value string
*/
public function setLog($value)
{
$this->_validateString('Log', $value);
@ -429,18 +409,17 @@ class BuildBase extends Model
if ($this->data['log'] === $value) {
return;
}
$this->data['log'] = $value;
$this->_setModified('log');
}
/**
* Set the value of Branch / branch.
*
* Must not be null.
* @param $value string
*/
* Set the value of Branch / branch.
*
* Must not be null.
*
* @param $value string
*/
public function setBranch($value)
{
$this->_validateNotNull('Branch', $value);
@ -449,17 +428,15 @@ class BuildBase extends Model
if ($this->data['branch'] === $value) {
return;
}
$this->data['branch'] = $value;
$this->_setModified('branch');
}
/**
* Set the value of Created / created.
*
* @param $value \DateTime
*/
* Set the value of Created / created.
*
* @param $value \DateTime
*/
public function setCreated($value)
{
$this->_validateDate('Created', $value);
@ -467,17 +444,15 @@ class BuildBase extends Model
if ($this->data['created'] === $value) {
return;
}
$this->data['created'] = $value;
$this->_setModified('created');
}
/**
* Set the value of Started / started.
*
* @param $value \DateTime
*/
* Set the value of Started / started.
*
* @param $value \DateTime
*/
public function setStarted($value)
{
$this->_validateDate('Started', $value);
@ -485,17 +460,15 @@ class BuildBase extends Model
if ($this->data['started'] === $value) {
return;
}
$this->data['started'] = $value;
$this->_setModified('started');
}
/**
* Set the value of Finished / finished.
*
* @param $value \DateTime
*/
* Set the value of Finished / finished.
*
* @param $value \DateTime
*/
public function setFinished($value)
{
$this->_validateDate('Finished', $value);
@ -503,17 +476,15 @@ class BuildBase extends Model
if ($this->data['finished'] === $value) {
return;
}
$this->data['finished'] = $value;
$this->_setModified('finished');
}
/**
* Set the value of Plugins / plugins.
*
* @param $value string
*/
* Set the value of Plugins / plugins.
*
* @param $value string
*/
public function setPlugins($value)
{
$this->_validateString('Plugins', $value);
@ -521,17 +492,15 @@ class BuildBase extends Model
if ($this->data['plugins'] === $value) {
return;
}
$this->data['plugins'] = $value;
$this->_setModified('plugins');
}
/**
* Set the value of CommitterEmail / committer_email.
*
* @param $value string
*/
* Set the value of CommitterEmail / committer_email.
*
* @param $value string
*/
public function setCommitterEmail($value)
{
$this->_validateString('CommitterEmail', $value);
@ -539,17 +508,15 @@ class BuildBase extends Model
if ($this->data['committer_email'] === $value) {
return;
}
$this->data['committer_email'] = $value;
$this->_setModified('committer_email');
}
/**
* Set the value of CommitMessage / commit_message.
*
* @param $value string
*/
* Set the value of CommitMessage / commit_message.
*
* @param $value string
*/
public function setCommitMessage($value)
{
$this->_validateString('CommitMessage', $value);
@ -557,9 +524,7 @@ class BuildBase extends Model
if ($this->data['commit_message'] === $value) {
return;
}
$this->data['commit_message'] = $value;
$this->_setModified('commit_message');
}
@ -578,22 +543,21 @@ class BuildBase extends Model
return null;
}
$cacheKey = 'Cache.Project.' . $key;
$rtn = $this->cache->get($cacheKey, null);
$cacheKey = 'Cache.Project.' . $key;
$rtn = $this->cache->get($cacheKey, null);
if (empty($rtn)) {
$rtn = Factory::getStore('Project', 'PHPCI')->getById($key);
$rtn = Factory::getStore('Project', 'PHPCI')->getById($key);
$this->cache->set($cacheKey, $rtn);
}
return $rtn;
}
/**
* Set Project - Accepts an ID, an array representing a Project or a Project model.
*
* @param $value mixed
*/
* Set Project - Accepts an ID, an array representing a Project or a Project model.
*
* @param $value mixed
*/
public function setProject($value)
{
// Is this an instance of Project?
@ -611,15 +575,16 @@ class BuildBase extends Model
}
/**
* Set Project - Accepts a Project model.
*
* @param $value \PHPCI\Model\Project
*/
* Set Project - Accepts a Project model.
*
* @param $value \PHPCI\Model\Project
*/
public function setProjectObject(\PHPCI\Model\Project $value)
{
return $this->setProjectId($value->getId());
}
/**
* Get BuildMeta models by BuildId for this Build.
*
@ -632,15 +597,11 @@ class BuildBase extends Model
return Factory::getStore('BuildMeta', 'PHPCI')->getByBuildId($this->getId());
}
public static function getByPrimaryKey($value, $useConnection = 'read')
{
return Factory::getStore('Build', 'PHPCI')->getByPrimaryKey($value, $useConnection);
}
public static function getById($value, $useConnection = 'read')
{
return Factory::getStore('Build', 'PHPCI')->getById($value, $useConnection);
@ -655,7 +616,4 @@ class BuildBase extends Model
{
return Factory::getStore('Build', 'PHPCI')->getByStatus($value, $limit, $useConnection);
}
}

View file

@ -15,182 +15,176 @@ use b8\Store\Factory;
class BuildMetaBase extends Model
{
/**
* @var array
*/
* @var array
*/
public static $sleepable = array();
/**
* @var string
*/
* @var string
*/
protected $tableName = 'build_meta';
/**
* @var string
*/
* @var string
*/
protected $modelName = 'BuildMeta';
/**
* @var array
*/
* @var array
*/
protected $data = array(
'id' => null,
'id' => null,
'project_id' => null,
'build_id' => null,
'meta_key' => null,
'build_id' => null,
'meta_key' => null,
'meta_value' => null,
);
/**
* @var array
*/
* @var array
*/
protected $getters = array(
// Direct property getters:
'id' => 'getId',
'id' => 'getId',
'project_id' => 'getProjectId',
'build_id' => 'getBuildId',
'meta_key' => 'getMetaKey',
'build_id' => 'getBuildId',
'meta_key' => 'getMetaKey',
'meta_value' => 'getMetaValue',
// Foreign key getters:
'Build' => 'getBuild',
'Build' => 'getBuild',
);
/**
* @var array
*/
* @var array
*/
protected $setters = array(
// Direct property setters:
'id' => 'setId',
'id' => 'setId',
'project_id' => 'setProjectId',
'build_id' => 'setBuildId',
'meta_key' => 'setMetaKey',
'build_id' => 'setBuildId',
'meta_key' => 'setMetaKey',
'meta_value' => 'setMetaValue',
// Foreign key setters:
'Build' => 'setBuild',
'Build' => 'setBuild',
);
/**
* @var array
*/
* @var array
*/
public $columns = array(
'id' => array(
'type' => 'int',
'length' => 10,
'primary_key' => true,
'id' => array(
'type' => 'int',
'length' => 10,
'primary_key' => true,
'auto_increment' => true,
'default' => null,
'default' => null,
),
'project_id' => array(
'type' => 'int',
'length' => 11,
'type' => 'int',
'length' => 11,
'default' => null,
),
'build_id' => array(
'type' => 'int',
'length' => 11,
'build_id' => array(
'type' => 'int',
'length' => 11,
'nullable' => true,
'default' => null,
'default' => null,
),
'meta_key' => array(
'type' => 'varchar',
'length' => 255,
'meta_key' => array(
'type' => 'varchar',
'length' => 255,
'default' => null,
),
'meta_value' => array(
'type' => 'text',
'type' => 'text',
'nullable' => true,
'default' => null,
'default' => null,
),
);
/**
* @var array
*/
* @var array
*/
public $indexes = array(
'PRIMARY' => array('unique' => true, 'columns' => 'id'),
'idx_meta_id' => array('unique' => true, 'columns' => 'build_id, meta_key'),
'PRIMARY' => array('unique' => true, 'columns' => 'id'),
'idx_meta_id' => array('unique' => true, 'columns' => 'build_id, meta_key'),
);
/**
* @var array
*/
* @var array
*/
public $foreignKeys = array(
'fk_meta_build_id' => array(
'local_col' => 'build_id',
'update' => 'CASCADE',
'delete' => 'CASCADE',
'table' => 'build',
'col' => 'id'
),
'fk_meta_build_id' => array(
'local_col' => 'build_id',
'update' => 'CASCADE',
'delete' => 'CASCADE',
'table' => 'build',
'col' => 'id'
),
);
/**
* Get the value of Id / id.
*
* @return int
*/
* Get the value of Id / id.
*
* @return int
*/
public function getId()
{
$rtn = $this->data['id'];
$rtn = $this->data['id'];
return $rtn;
}
/**
* Get the value of ProjectId / project_id.
*
* @return int
*/
* Get the value of ProjectId / project_id.
*
* @return int
*/
public function getProjectId()
{
$rtn = $this->data['project_id'];
$rtn = $this->data['project_id'];
return $rtn;
}
/**
* Get the value of BuildId / build_id.
*
* @return int
*/
* Get the value of BuildId / build_id.
*
* @return int
*/
public function getBuildId()
{
$rtn = $this->data['build_id'];
$rtn = $this->data['build_id'];
return $rtn;
}
/**
* Get the value of MetaKey / meta_key.
*
* @return string
*/
* Get the value of MetaKey / meta_key.
*
* @return string
*/
public function getMetaKey()
{
$rtn = $this->data['meta_key'];
$rtn = $this->data['meta_key'];
return $rtn;
}
/**
* Get the value of MetaValue / meta_value.
*
* @return string
*/
* Get the value of MetaValue / meta_value.
*
* @return string
*/
public function getMetaValue()
{
$rtn = $this->data['meta_value'];
$rtn = $this->data['meta_value'];
return $rtn;
}
/**
* Set the value of Id / id.
*
* Must not be null.
* @param $value int
*/
* Set the value of Id / id.
*
* Must not be null.
*
* @param $value int
*/
public function setId($value)
{
$this->_validateNotNull('Id', $value);
@ -199,18 +193,17 @@ class BuildMetaBase extends Model
if ($this->data['id'] === $value) {
return;
}
$this->data['id'] = $value;
$this->_setModified('id');
}
/**
* Set the value of ProjectId / project_id.
*
* Must not be null.
* @param $value int
*/
* Set the value of ProjectId / project_id.
*
* Must not be null.
*
* @param $value int
*/
public function setProjectId($value)
{
$this->_validateNotNull('ProjectId', $value);
@ -219,17 +212,15 @@ class BuildMetaBase extends Model
if ($this->data['project_id'] === $value) {
return;
}
$this->data['project_id'] = $value;
$this->_setModified('project_id');
}
/**
* Set the value of BuildId / build_id.
*
* @param $value int
*/
* Set the value of BuildId / build_id.
*
* @param $value int
*/
public function setBuildId($value)
{
$this->_validateInt('BuildId', $value);
@ -237,18 +228,17 @@ class BuildMetaBase extends Model
if ($this->data['build_id'] === $value) {
return;
}
$this->data['build_id'] = $value;
$this->_setModified('build_id');
}
/**
* Set the value of MetaKey / meta_key.
*
* Must not be null.
* @param $value string
*/
* Set the value of MetaKey / meta_key.
*
* Must not be null.
*
* @param $value string
*/
public function setMetaKey($value)
{
$this->_validateNotNull('MetaKey', $value);
@ -257,17 +247,15 @@ class BuildMetaBase extends Model
if ($this->data['meta_key'] === $value) {
return;
}
$this->data['meta_key'] = $value;
$this->_setModified('meta_key');
}
/**
* Set the value of MetaValue / meta_value.
*
* @param $value string
*/
* Set the value of MetaValue / meta_value.
*
* @param $value string
*/
public function setMetaValue($value)
{
$this->_validateString('MetaValue', $value);
@ -275,9 +263,7 @@ class BuildMetaBase extends Model
if ($this->data['meta_value'] === $value) {
return;
}
$this->data['meta_value'] = $value;
$this->_setModified('meta_value');
}
@ -296,22 +282,21 @@ class BuildMetaBase extends Model
return null;
}
$cacheKey = 'Cache.Build.' . $key;
$rtn = $this->cache->get($cacheKey, null);
$cacheKey = 'Cache.Build.' . $key;
$rtn = $this->cache->get($cacheKey, null);
if (empty($rtn)) {
$rtn = Factory::getStore('Build', 'PHPCI')->getById($key);
$rtn = Factory::getStore('Build', 'PHPCI')->getById($key);
$this->cache->set($cacheKey, $rtn);
}
return $rtn;
}
/**
* Set Build - Accepts an ID, an array representing a Build or a Build model.
*
* @param $value mixed
*/
* Set Build - Accepts an ID, an array representing a Build or a Build model.
*
* @param $value mixed
*/
public function setBuild($value)
{
// Is this an instance of Build?
@ -329,24 +314,20 @@ class BuildMetaBase extends Model
}
/**
* Set Build - Accepts a Build model.
*
* @param $value \PHPCI\Model\Build
*/
* Set Build - Accepts a Build model.
*
* @param $value \PHPCI\Model\Build
*/
public function setBuildObject(\PHPCI\Model\Build $value)
{
return $this->setBuildId($value->getId());
}
public static function getByPrimaryKey($value, $useConnection = 'read')
{
return Factory::getStore('BuildMeta', 'PHPCI')->getByPrimaryKey($value, $useConnection);
}
public static function getById($value, $useConnection = 'read')
{
return Factory::getStore('BuildMeta', 'PHPCI')->getById($value, $useConnection);
@ -356,7 +337,4 @@ class BuildMetaBase extends Model
{
return Factory::getStore('BuildMeta', 'PHPCI')->getByBuildId($value, $limit, $useConnection);
}
}

View file

@ -15,235 +15,244 @@ use b8\Store\Factory;
class ProjectBase extends Model
{
/**
* @var array
*/
* @var array
*/
public static $sleepable = array();
/**
* @var string
*/
* @var string
*/
protected $tableName = 'project';
/**
* @var string
*/
* @var string
*/
protected $modelName = 'Project';
/**
* @var array
*/
* @var array
*/
protected $data = array(
'id' => null,
'title' => null,
'reference' => null,
'git_key' => null,
'type' => null,
'token' => null,
'id' => null,
'title' => null,
'reference' => null,
'git_key' => null,
'build_config' => null,
'type' => null,
'token' => null,
'access_information' => null,
'last_commit' => null,
'last_commit' => null,
);
/**
* @var array
*/
* @var array
*/
protected $getters = array(
// Direct property getters:
'id' => 'getId',
'title' => 'getTitle',
'reference' => 'getReference',
'git_key' => 'getGitKey',
'type' => 'getType',
'token' => 'getToken',
'id' => 'getId',
'title' => 'getTitle',
'reference' => 'getReference',
'git_key' => 'getGitKey',
'build_config' => 'getBuildConfig',
'type' => 'getType',
'token' => 'getToken',
'access_information' => 'getAccessInformation',
'last_commit' => 'getLastCommit',
'last_commit' => 'getLastCommit',
// Foreign key getters:
);
/**
* @var array
*/
* @var array
*/
protected $setters = array(
// Direct property setters:
'id' => 'setId',
'title' => 'setTitle',
'reference' => 'setReference',
'git_key' => 'setGitKey',
'type' => 'setType',
'token' => 'setToken',
'id' => 'setId',
'title' => 'setTitle',
'reference' => 'setReference',
'git_key' => 'setGitKey',
'build_config' => 'setBuildConfig',
'type' => 'setType',
'token' => 'setToken',
'access_information' => 'setAccessInformation',
'last_commit' => 'setLastCommit',
'last_commit' => 'setLastCommit',
// Foreign key setters:
);
/**
* @var array
*/
* @var array
*/
public $columns = array(
'id' => array(
'type' => 'int',
'length' => 11,
'primary_key' => true,
'id' => array(
'type' => 'int',
'length' => 11,
'primary_key' => true,
'auto_increment' => true,
'default' => null,
),
'title' => array(
'type' => 'varchar',
'length' => 250,
'default' => null,
),
'title' => array(
'type' => 'varchar',
'length' => 250,
'reference' => array(
'type' => 'varchar',
'length' => 250,
'default' => null,
),
'reference' => array(
'type' => 'varchar',
'length' => 250,
'default' => null,
),
'git_key' => array(
'type' => 'text',
'git_key' => array(
'type' => 'text',
'nullable' => true,
'default' => null,
'default' => null,
),
'type' => array(
'type' => 'varchar',
'length' => 50,
'build_config' => array(
'type' => 'text',
'nullable' => true,
'default' => null,
),
'type' => array(
'type' => 'varchar',
'length' => 50,
'default' => 1,
),
'token' => array(
'type' => 'varchar',
'length' => 50,
'token' => array(
'type' => 'varchar',
'length' => 50,
'nullable' => true,
'default' => null,
'default' => null,
),
'access_information' => array(
'type' => 'varchar',
'length' => 250,
'type' => 'varchar',
'length' => 250,
'nullable' => true,
'default' => null,
'default' => null,
),
'last_commit' => array(
'type' => 'varchar',
'length' => 250,
'last_commit' => array(
'type' => 'varchar',
'length' => 250,
'nullable' => true,
'default' => null,
'default' => null,
),
);
/**
* @var array
*/
* @var array
*/
public $indexes = array(
'PRIMARY' => array('unique' => true, 'columns' => 'id'),
'idx_project_title' => array('columns' => 'title'),
'PRIMARY' => array('unique' => true, 'columns' => 'id'),
'idx_project_title' => array('columns' => 'title'),
);
/**
* @var array
*/
public $foreignKeys = array(
);
* @var array
*/
public $foreignKeys = array();
/**
* Get the value of Id / id.
*
* @return int
*/
* Get the value of Id / id.
*
* @return int
*/
public function getId()
{
$rtn = $this->data['id'];
$rtn = $this->data['id'];
return $rtn;
}
/**
* Get the value of Title / title.
*
* @return string
*/
* Get the value of Title / title.
*
* @return string
*/
public function getTitle()
{
$rtn = $this->data['title'];
$rtn = $this->data['title'];
return $rtn;
}
/**
* Get the value of Reference / reference.
*
* @return string
*/
* Get the value of Reference / reference.
*
* @return string
*/
public function getReference()
{
$rtn = $this->data['reference'];
$rtn = $this->data['reference'];
return $rtn;
}
/**
* Get the value of GitKey / git_key.
*
* @return string
*/
* Get the value of GitKey / git_key.
*
* @return string
*/
public function getGitKey()
{
$rtn = $this->data['git_key'];
$rtn = $this->data['git_key'];
return $rtn;
}
/**
* Get the value of Type / type.
*
* @return string
*/
* Get the value of BuildConfig / build_config.
*
* @return string
*/
public function getBuildConfig()
{
$rtn = $this->data['build_config'];
return $rtn;
}
/**
* Get the value of Type / type.
*
* @return string
*/
public function getType()
{
$rtn = $this->data['type'];
$rtn = $this->data['type'];
return $rtn;
}
/**
* Get the value of Token / token.
*
* @return string
*/
* Get the value of Token / token.
*
* @return string
*/
public function getToken()
{
$rtn = $this->data['token'];
$rtn = $this->data['token'];
return $rtn;
}
/**
* Get the value of AccessInformation / access_information.
*
* @return string
*/
* Get the value of AccessInformation / access_information.
*
* @return string
*/
public function getAccessInformation()
{
$rtn = $this->data['access_information'];
$rtn = $this->data['access_information'];
return $rtn;
}
/**
* Get the value of LastCommit / last_commit.
*
* @return string
*/
* Get the value of LastCommit / last_commit.
*
* @return string
*/
public function getLastCommit()
{
$rtn = $this->data['last_commit'];
$rtn = $this->data['last_commit'];
return $rtn;
}
/**
* Set the value of Id / id.
*
* Must not be null.
* @param $value int
*/
* Set the value of Id / id.
*
* Must not be null.
*
* @param $value int
*/
public function setId($value)
{
$this->_validateNotNull('Id', $value);
@ -252,18 +261,17 @@ class ProjectBase extends Model
if ($this->data['id'] === $value) {
return;
}
$this->data['id'] = $value;
$this->_setModified('id');
}
/**
* Set the value of Title / title.
*
* Must not be null.
* @param $value string
*/
* Set the value of Title / title.
*
* Must not be null.
*
* @param $value string
*/
public function setTitle($value)
{
$this->_validateNotNull('Title', $value);
@ -272,18 +280,17 @@ class ProjectBase extends Model
if ($this->data['title'] === $value) {
return;
}
$this->data['title'] = $value;
$this->_setModified('title');
}
/**
* Set the value of Reference / reference.
*
* Must not be null.
* @param $value string
*/
* Set the value of Reference / reference.
*
* Must not be null.
*
* @param $value string
*/
public function setReference($value)
{
$this->_validateNotNull('Reference', $value);
@ -292,17 +299,15 @@ class ProjectBase extends Model
if ($this->data['reference'] === $value) {
return;
}
$this->data['reference'] = $value;
$this->_setModified('reference');
}
/**
* Set the value of GitKey / git_key.
*
* @param $value string
*/
* Set the value of GitKey / git_key.
*
* @param $value string
*/
public function setGitKey($value)
{
$this->_validateString('GitKey', $value);
@ -310,18 +315,33 @@ class ProjectBase extends Model
if ($this->data['git_key'] === $value) {
return;
}
$this->data['git_key'] = $value;
$this->_setModified('git_key');
}
/**
* Set the value of Type / type.
*
* Must not be null.
* @param $value string
*/
* Set the value of BuildConfig / build_config.
*
* @param $value string
*/
public function setBuildConfig($value)
{
$this->_validateString('BuildConfig', $value);
if ($this->data['build_config'] === $value) {
return;
}
$this->data['build_config'] = $value;
$this->_setModified('build_config');
}
/**
* Set the value of Type / type.
*
* Must not be null.
*
* @param $value string
*/
public function setType($value)
{
$this->_validateNotNull('Type', $value);
@ -330,17 +350,16 @@ class ProjectBase extends Model
if ($this->data['type'] === $value) {
return;
}
$this->data['type'] = $value;
$this->_setModified('type');
}
/**
* Set the value of Token / token.
*
* @param $value string
*/
* Set the value of Token / token.
*
* @param $value string
*/
public function setToken($value)
{
$this->_validateString('Token', $value);
@ -348,17 +367,15 @@ class ProjectBase extends Model
if ($this->data['token'] === $value) {
return;
}
$this->data['token'] = $value;
$this->_setModified('token');
}
/**
* Set the value of AccessInformation / access_information.
*
* @param $value string
*/
* Set the value of AccessInformation / access_information.
*
* @param $value string
*/
public function setAccessInformation($value)
{
$this->_validateString('AccessInformation', $value);
@ -366,17 +383,15 @@ class ProjectBase extends Model
if ($this->data['access_information'] === $value) {
return;
}
$this->data['access_information'] = $value;
$this->_setModified('access_information');
}
/**
* Set the value of LastCommit / last_commit.
*
* @param $value string
*/
* Set the value of LastCommit / last_commit.
*
* @param $value string
*/
public function setLastCommit($value)
{
$this->_validateString('LastCommit', $value);
@ -384,9 +399,7 @@ class ProjectBase extends Model
if ($this->data['last_commit'] === $value) {
return;
}
$this->data['last_commit'] = $value;
$this->_setModified('last_commit');
}
@ -402,15 +415,11 @@ class ProjectBase extends Model
return Factory::getStore('Build', 'PHPCI')->getByProjectId($this->getId());
}
public static function getByPrimaryKey($value, $useConnection = 'read')
{
return Factory::getStore('Project', 'PHPCI')->getByPrimaryKey($value, $useConnection);
}
public static function getById($value, $useConnection = 'read')
{
return Factory::getStore('Project', 'PHPCI')->getById($value, $useConnection);
@ -420,7 +429,4 @@ class ProjectBase extends Model
{
return Factory::getStore('Project', 'PHPCI')->getByTitle($value, $limit, $useConnection);
}
}

View file

@ -15,173 +15,168 @@ use b8\Store\Factory;
class UserBase extends Model
{
/**
* @var array
*/
* @var array
*/
public static $sleepable = array();
/**
* @var string
*/
* @var string
*/
protected $tableName = 'user';
/**
* @var string
*/
* @var string
*/
protected $modelName = 'User';
/**
* @var array
*/
* @var array
*/
protected $data = array(
'id' => null,
'email' => null,
'hash' => null,
'id' => null,
'email' => null,
'hash' => null,
'is_admin' => null,
'name' => null,
'name' => null,
);
/**
* @var array
*/
* @var array
*/
protected $getters = array(
// Direct property getters:
'id' => 'getId',
'email' => 'getEmail',
'hash' => 'getHash',
'id' => 'getId',
'email' => 'getEmail',
'hash' => 'getHash',
'is_admin' => 'getIsAdmin',
'name' => 'getName',
'name' => 'getName',
// Foreign key getters:
);
/**
* @var array
*/
* @var array
*/
protected $setters = array(
// Direct property setters:
'id' => 'setId',
'email' => 'setEmail',
'hash' => 'setHash',
'id' => 'setId',
'email' => 'setEmail',
'hash' => 'setHash',
'is_admin' => 'setIsAdmin',
'name' => 'setName',
'name' => 'setName',
// Foreign key setters:
);
/**
* @var array
*/
* @var array
*/
public $columns = array(
'id' => array(
'type' => 'int',
'length' => 11,
'primary_key' => true,
'id' => array(
'type' => 'int',
'length' => 11,
'primary_key' => true,
'auto_increment' => true,
'default' => null,
),
'email' => array(
'type' => 'varchar',
'length' => 250,
'default' => null,
),
'email' => array(
'type' => 'varchar',
'length' => 250,
'default' => null,
),
'hash' => array(
'type' => 'varchar',
'length' => 250,
'hash' => array(
'type' => 'varchar',
'length' => 250,
'default' => null,
),
'is_admin' => array(
'type' => 'tinyint',
'length' => 1,
'type' => 'tinyint',
'length' => 1,
'default' => null,
),
'name' => array(
'type' => 'varchar',
'length' => 250,
'name' => array(
'type' => 'varchar',
'length' => 250,
'nullable' => true,
'default' => null,
'default' => null,
),
);
/**
* @var array
*/
* @var array
*/
public $indexes = array(
'PRIMARY' => array('unique' => true, 'columns' => 'id'),
'idx_email' => array('unique' => true, 'columns' => 'email'),
'PRIMARY' => array('unique' => true, 'columns' => 'id'),
'idx_email' => array('unique' => true, 'columns' => 'email'),
);
/**
* @var array
*/
public $foreignKeys = array(
);
* @var array
*/
public $foreignKeys = array();
/**
* Get the value of Id / id.
*
* @return int
*/
* Get the value of Id / id.
*
* @return int
*/
public function getId()
{
$rtn = $this->data['id'];
$rtn = $this->data['id'];
return $rtn;
}
/**
* Get the value of Email / email.
*
* @return string
*/
* Get the value of Email / email.
*
* @return string
*/
public function getEmail()
{
$rtn = $this->data['email'];
$rtn = $this->data['email'];
return $rtn;
}
/**
* Get the value of Hash / hash.
*
* @return string
*/
* Get the value of Hash / hash.
*
* @return string
*/
public function getHash()
{
$rtn = $this->data['hash'];
$rtn = $this->data['hash'];
return $rtn;
}
/**
* Get the value of IsAdmin / is_admin.
*
* @return int
*/
* Get the value of IsAdmin / is_admin.
*
* @return int
*/
public function getIsAdmin()
{
$rtn = $this->data['is_admin'];
$rtn = $this->data['is_admin'];
return $rtn;
}
/**
* Get the value of Name / name.
*
* @return string
*/
* Get the value of Name / name.
*
* @return string
*/
public function getName()
{
$rtn = $this->data['name'];
$rtn = $this->data['name'];
return $rtn;
}
/**
* Set the value of Id / id.
*
* Must not be null.
* @param $value int
*/
* Set the value of Id / id.
*
* Must not be null.
*
* @param $value int
*/
public function setId($value)
{
$this->_validateNotNull('Id', $value);
@ -190,18 +185,17 @@ class UserBase extends Model
if ($this->data['id'] === $value) {
return;
}
$this->data['id'] = $value;
$this->_setModified('id');
}
/**
* Set the value of Email / email.
*
* Must not be null.
* @param $value string
*/
* Set the value of Email / email.
*
* Must not be null.
*
* @param $value string
*/
public function setEmail($value)
{
$this->_validateNotNull('Email', $value);
@ -210,18 +204,17 @@ class UserBase extends Model
if ($this->data['email'] === $value) {
return;
}
$this->data['email'] = $value;
$this->_setModified('email');
}
/**
* Set the value of Hash / hash.
*
* Must not be null.
* @param $value string
*/
* Set the value of Hash / hash.
*
* Must not be null.
*
* @param $value string
*/
public function setHash($value)
{
$this->_validateNotNull('Hash', $value);
@ -230,18 +223,17 @@ class UserBase extends Model
if ($this->data['hash'] === $value) {
return;
}
$this->data['hash'] = $value;
$this->_setModified('hash');
}
/**
* Set the value of IsAdmin / is_admin.
*
* Must not be null.
* @param $value int
*/
* Set the value of IsAdmin / is_admin.
*
* Must not be null.
*
* @param $value int
*/
public function setIsAdmin($value)
{
$this->_validateNotNull('IsAdmin', $value);
@ -250,17 +242,15 @@ class UserBase extends Model
if ($this->data['is_admin'] === $value) {
return;
}
$this->data['is_admin'] = $value;
$this->_setModified('is_admin');
}
/**
* Set the value of Name / name.
*
* @param $value string
*/
* Set the value of Name / name.
*
* @param $value string
*/
public function setName($value)
{
$this->_validateString('Name', $value);
@ -268,21 +258,15 @@ class UserBase extends Model
if ($this->data['name'] === $value) {
return;
}
$this->data['name'] = $value;
$this->_setModified('name');
}
public static function getByPrimaryKey($value, $useConnection = 'read')
{
return Factory::getStore('User', 'PHPCI')->getByPrimaryKey($value, $useConnection);
}
public static function getById($value, $useConnection = 'read')
{
return Factory::getStore('User', 'PHPCI')->getById($value, $useConnection);
@ -292,7 +276,4 @@ class UserBase extends Model
{
return Factory::getStore('User', 'PHPCI')->getByEmail($value, $useConnection);
}
}

View file

@ -11,6 +11,8 @@ namespace PHPCI\Model;
use b8\Store\Factory;
use PHPCI\Model\Base\BuildBase;
use PHPCI\Builder;
use Symfony\Component\Yaml\Parser as YamlParser;
/**
* Build Model
@ -77,4 +79,29 @@ class Build extends BuildBase
{
return ($this->getStatus() === self::STATUS_SUCCESS);
}
/**
* @param Builder $builder
* @param string $buildPath
*
* @return bool
*/
protected function handleConfig(Builder $builder, $buildPath)
{
if (is_file($buildPath . '/phpci.yml')) {
$build_config = file_get_contents($buildPath . '/phpci.yml');
}
if (!is_file($buildPath . '/phpci.yml') || !$build_config) {
$build_config = $this->getProject()->getBuildConfig();
if (!$build_config) {
$builder->logFailure('Project does not contain a phpci.yml file.');
return false;
}
}
$yamlParser = new YamlParser();
$builder->setConfigArray($yamlParser->parse($build_config));
return $builder->getConfig('build_settings');
}
}

View file

@ -11,7 +11,6 @@ namespace PHPCI\Model\Build;
use PHPCI\Model\Build;
use PHPCI\Builder;
use Symfony\Component\Yaml\Parser as YamlParser;
/**
* Local Build Model
@ -83,18 +82,4 @@ class LocalBuild extends Build
return true;
}
protected function handleConfig(Builder $builder, $reference)
{
/** @todo Add support for database-based yml definition */
if (!is_file($reference . '/phpci.yml')) {
$builder->logFailure('Project does not contain a phpci.yml file.');
return false;
}
$yamlParser = new YamlParser();
$yamlFile = file_get_contents($reference . '/phpci.yml');
$builder->setConfigArray($yamlParser->parse($yamlFile));
return $builder->getConfig('build_settings');
}
}

View file

@ -11,7 +11,6 @@ namespace PHPCI\Model\Build;
use PHPCI\Model\Build;
use PHPCI\Builder;
use Symfony\Component\Yaml\Parser as YamlParser;
/**
* Mercurial Build Model
@ -34,19 +33,9 @@ class MercurialBuild extends Build
*/
public function createWorkingCopy(Builder $builder, $buildPath)
{
$yamlParser = new YamlParser();
$this->cloneByHttp($builder, $buildPath);
if (!is_file($buildPath . 'phpci.yml')) {
$builder->logFailure('Project does not contain a phpci.yml file.');
return false;
}
$yamlFile = file_get_contents($buildPath . 'phpci.yml');
$builder->setConfigArray($yamlParser->parse($yamlFile));
return true;
return $this->handleConfig($builder, $buildPath);
}
/**

View file

@ -11,7 +11,6 @@ namespace PHPCI\Model\Build;
use PHPCI\Model\Build;
use PHPCI\Builder;
use Symfony\Component\Yaml\Parser as YamlParser;
/**
* Remote Git Build Model
@ -34,7 +33,6 @@ class RemoteGitBuild extends Build
*/
public function createWorkingCopy(Builder $builder, $buildPath)
{
$yamlParser = new YamlParser();
$key = trim($this->getProject()->getGitKey());
if (!empty($key)) {
@ -48,15 +46,7 @@ class RemoteGitBuild extends Build
return false;
}
if (!is_file($buildPath . 'phpci.yml')) {
$builder->logFailure('Project does not contain a phpci.yml file.');
return false;
}
$yamlFile = file_get_contents($buildPath . 'phpci.yml');
$builder->setConfigArray($yamlParser->parse($yamlFile));
return true;
return $this->handleConfig($builder, $buildPath);
}
/**

View file

@ -16,9 +16,11 @@ use PHPCI\Model\BuildMeta;
*/
class BuildMetaStoreBase extends Store
{
protected $tableName = 'build_meta';
protected $modelName = '\PHPCI\Model\BuildMeta';
protected $primaryKey = 'id';
protected $tableName = 'build_meta';
protected $modelName = '\PHPCI\Model\BuildMeta';
protected $primaryKey = 'id';
public function getByPrimaryKey($value, $useConnection = 'read')
{
@ -32,7 +34,7 @@ class BuildMetaStoreBase extends Store
}
$query = 'SELECT * FROM `build_meta` WHERE `id` = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepare($query);
$stmt = Database::getConnection($useConnection)->prepare($query);
$stmt->bindValue(':id', $value);
if ($stmt->execute()) {
@ -40,7 +42,6 @@ class BuildMetaStoreBase extends Store
return new BuildMeta($data);
}
}
return null;
}
@ -51,15 +52,13 @@ class BuildMetaStoreBase extends Store
}
$add = '';
if ($limit) {
$add .= ' LIMIT ' . $limit;
}
$count = null;
$query = 'SELECT * FROM `build_meta` WHERE `build_id` = :build_id' . $add;
$stmt = Database::getConnection($useConnection)->prepare($query);
$stmt = Database::getConnection($useConnection)->prepare($query);
$stmt->bindValue(':build_id', $value);
if ($stmt->execute()) {

View file

@ -16,9 +16,11 @@ use PHPCI\Model\Build;
*/
class BuildStoreBase extends Store
{
protected $tableName = 'build';
protected $modelName = '\PHPCI\Model\Build';
protected $primaryKey = 'id';
protected $tableName = 'build';
protected $modelName = '\PHPCI\Model\Build';
protected $primaryKey = 'id';
public function getByPrimaryKey($value, $useConnection = 'read')
{
@ -32,7 +34,7 @@ class BuildStoreBase extends Store
}
$query = 'SELECT * FROM `build` WHERE `id` = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepare($query);
$stmt = Database::getConnection($useConnection)->prepare($query);
$stmt->bindValue(':id', $value);
if ($stmt->execute()) {
@ -40,7 +42,6 @@ class BuildStoreBase extends Store
return new Build($data);
}
}
return null;
}
@ -51,15 +52,13 @@ class BuildStoreBase extends Store
}
$add = '';
if ($limit) {
$add .= ' LIMIT ' . $limit;
}
$count = null;
$query = 'SELECT * FROM `build` WHERE `project_id` = :project_id' . $add;
$stmt = Database::getConnection($useConnection)->prepare($query);
$stmt = Database::getConnection($useConnection)->prepare($query);
$stmt->bindValue(':project_id', $value);
if ($stmt->execute()) {
@ -83,15 +82,13 @@ class BuildStoreBase extends Store
}
$add = '';
if ($limit) {
$add .= ' LIMIT ' . $limit;
}
$count = null;
$query = 'SELECT * FROM `build` WHERE `status` = :status' . $add;
$stmt = Database::getConnection($useConnection)->prepare($query);
$stmt = Database::getConnection($useConnection)->prepare($query);
$stmt->bindValue(':status', $value);
if ($stmt->execute()) {

View file

@ -16,9 +16,11 @@ use PHPCI\Model\Project;
*/
class ProjectStoreBase extends Store
{
protected $tableName = 'project';
protected $modelName = '\PHPCI\Model\Project';
protected $primaryKey = 'id';
protected $tableName = 'project';
protected $modelName = '\PHPCI\Model\Project';
protected $primaryKey = 'id';
public function getByPrimaryKey($value, $useConnection = 'read')
{
@ -32,7 +34,7 @@ class ProjectStoreBase extends Store
}
$query = 'SELECT * FROM `project` WHERE `id` = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepare($query);
$stmt = Database::getConnection($useConnection)->prepare($query);
$stmt->bindValue(':id', $value);
if ($stmt->execute()) {
@ -40,7 +42,6 @@ class ProjectStoreBase extends Store
return new Project($data);
}
}
return null;
}
@ -51,15 +52,13 @@ class ProjectStoreBase extends Store
}
$add = '';
if ($limit) {
$add .= ' LIMIT ' . $limit;
}
$count = null;
$query = 'SELECT * FROM `project` WHERE `title` = :title' . $add;
$stmt = Database::getConnection($useConnection)->prepare($query);
$stmt = Database::getConnection($useConnection)->prepare($query);
$stmt->bindValue(':title', $value);
if ($stmt->execute()) {

View file

@ -16,9 +16,11 @@ use PHPCI\Model\User;
*/
class UserStoreBase extends Store
{
protected $tableName = 'user';
protected $modelName = '\PHPCI\Model\User';
protected $primaryKey = 'id';
protected $tableName = 'user';
protected $modelName = '\PHPCI\Model\User';
protected $primaryKey = 'id';
public function getByPrimaryKey($value, $useConnection = 'read')
{
@ -32,7 +34,7 @@ class UserStoreBase extends Store
}
$query = 'SELECT * FROM `user` WHERE `id` = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepare($query);
$stmt = Database::getConnection($useConnection)->prepare($query);
$stmt->bindValue(':id', $value);
if ($stmt->execute()) {
@ -40,7 +42,6 @@ class UserStoreBase extends Store
return new User($data);
}
}
return null;
}
@ -51,7 +52,7 @@ class UserStoreBase extends Store
}
$query = 'SELECT * FROM `user` WHERE `email` = :email LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepare($query);
$stmt = Database::getConnection($useConnection)->prepare($query);
$stmt->bindValue(':email', $value);
if ($stmt->execute()) {
@ -59,7 +60,6 @@ class UserStoreBase extends Store
return new User($data);
}
}
return null;
}
}