diff --git a/PHPCI/Controller/ProjectController.php b/PHPCI/Controller/ProjectController.php index 2ecc177b..fa279eaf 100644 --- a/PHPCI/Controller/ProjectController.php +++ b/PHPCI/Controller/ProjectController.php @@ -212,6 +212,7 @@ class ProjectController extends \PHPCI\Controller } $values['git_key'] = $values['key']; + $values['public_key'] = $values['pubkey']; $project = new Project(); $project->setValues($values); @@ -242,6 +243,7 @@ class ProjectController extends \PHPCI\Controller } else { $values = $project->getDataArray(); $values['key'] = $values['git_key']; + $values['pubkey'] = $values['public_key']; if ($values['type'] == "gitlab") { $accessInfo = $project->getAccessInformation(); @@ -265,6 +267,7 @@ class ProjectController extends \PHPCI\Controller $values = $form->getValues(); $values['git_key'] = $values['key']; + $values['public_key'] = $values['pubkey']; if ($values['type'] == "gitlab") { preg_match('`^(.*)@(.*):(.*)/(.*)\.git`', $values['reference'], $matches); diff --git a/PHPCI/Model/Base/BuildBase.php b/PHPCI/Model/Base/BuildBase.php index 02dd6280..59e4c21e 100644 --- a/PHPCI/Model/Base/BuildBase.php +++ b/PHPCI/Model/Base/BuildBase.php @@ -3,6 +3,7 @@ /** * Build base model for table: build */ + namespace PHPCI\Model\Base; use PHPCI\Model; @@ -14,323 +15,336 @@ 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, ), - 'commit_id' => array( - 'type' => 'varchar', - 'length' => 50, - 'nullable' => true, - 'default' => null, - ), - 'status' => array( - 'type' => 'tinyint', - 'length' => 4, + 'project_id' => array( + 'type' => 'int', + 'length' => 11, 'default' => null, ), - 'log' => array( - 'type' => 'longtext', + 'commit_id' => array( + 'type' => 'varchar', + 'length' => 50, 'nullable' => true, - 'default' => null, + 'default' => null, ), - 'branch' => array( - 'type' => 'varchar', - 'length' => 50, + 'status' => array( + 'type' => 'tinyint', + 'length' => 4, + 'default' => null, + ), + 'log' => array( + 'type' => 'longtext', + 'nullable' => true, + 'default' => null, + ), + '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); @@ -339,17 +353,18 @@ 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); @@ -358,15 +373,17 @@ 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); @@ -374,17 +391,18 @@ 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); @@ -393,15 +411,17 @@ 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); @@ -409,17 +429,18 @@ 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); @@ -428,15 +449,17 @@ 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); @@ -444,15 +467,17 @@ 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); @@ -460,15 +485,17 @@ 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); @@ -476,15 +503,17 @@ 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); @@ -492,15 +521,17 @@ 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); @@ -508,15 +539,17 @@ 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); @@ -524,7 +557,9 @@ class BuildBase extends Model if ($this->data['commit_message'] === $value) { return; } + $this->data['commit_message'] = $value; + $this->_setModified('commit_message'); } @@ -543,21 +578,22 @@ 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? @@ -575,16 +611,15 @@ 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. * @@ -597,11 +632,15 @@ 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); @@ -616,4 +655,7 @@ class BuildBase extends Model { return Factory::getStore('Build', 'PHPCI')->getByStatus($value, $limit, $useConnection); } + + + } diff --git a/PHPCI/Model/Base/BuildMetaBase.php b/PHPCI/Model/Base/BuildMetaBase.php index 7c360075..83333102 100644 --- a/PHPCI/Model/Base/BuildMetaBase.php +++ b/PHPCI/Model/Base/BuildMetaBase.php @@ -15,176 +15,182 @@ 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, - ), - 'project_id' => array( - 'type' => 'int', - 'length' => 11, 'default' => null, ), - 'build_id' => array( - 'type' => 'int', - 'length' => 11, - 'nullable' => true, - 'default' => null, + 'project_id' => array( + 'type' => 'int', + 'length' => 11, + 'default' => null, ), - 'meta_key' => array( - 'type' => 'varchar', - 'length' => 255, + 'build_id' => array( + 'type' => 'int', + 'length' => 11, + 'nullable' => true, + 'default' => null, + ), + '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); @@ -193,17 +199,18 @@ 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); @@ -212,15 +219,17 @@ 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); @@ -228,17 +237,18 @@ 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); @@ -247,15 +257,17 @@ 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); @@ -263,7 +275,9 @@ class BuildMetaBase extends Model if ($this->data['meta_value'] === $value) { return; } + $this->data['meta_value'] = $value; + $this->_setModified('meta_value'); } @@ -282,21 +296,22 @@ 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? @@ -314,20 +329,24 @@ 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); @@ -337,4 +356,7 @@ class BuildMetaBase extends Model { return Factory::getStore('BuildMeta', 'PHPCI')->getByBuildId($value, $limit, $useConnection); } + + + } diff --git a/PHPCI/Model/Base/ProjectBase.php b/PHPCI/Model/Base/ProjectBase.php index b208bfff..c58f2016 100644 --- a/PHPCI/Model/Base/ProjectBase.php +++ b/PHPCI/Model/Base/ProjectBase.php @@ -15,244 +15,275 @@ 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, - 'build_config' => null, - 'type' => null, - 'token' => null, + 'id' => null, + 'title' => null, + 'reference' => null, + 'git_key' => null, + 'public_key' => null, + 'type' => null, + 'token' => null, 'access_information' => null, - 'last_commit' => null, + 'last_commit' => null, + 'build_config' => null, ); /** - * @var array - */ + * @var array + */ protected $getters = array( // Direct property getters: - 'id' => 'getId', - 'title' => 'getTitle', - 'reference' => 'getReference', - 'git_key' => 'getGitKey', - 'build_config' => 'getBuildConfig', - 'type' => 'getType', - 'token' => 'getToken', + 'id' => 'getId', + 'title' => 'getTitle', + 'reference' => 'getReference', + 'git_key' => 'getGitKey', + 'public_key' => 'getPublicKey', + 'type' => 'getType', + 'token' => 'getToken', 'access_information' => 'getAccessInformation', - 'last_commit' => 'getLastCommit', + 'last_commit' => 'getLastCommit', + 'build_config' => 'getBuildConfig', + // Foreign key getters: ); /** - * @var array - */ + * @var array + */ protected $setters = array( // Direct property setters: - 'id' => 'setId', - 'title' => 'setTitle', - 'reference' => 'setReference', - 'git_key' => 'setGitKey', - 'build_config' => 'setBuildConfig', - 'type' => 'setType', - 'token' => 'setToken', + 'id' => 'setId', + 'title' => 'setTitle', + 'reference' => 'setReference', + 'git_key' => 'setGitKey', + 'public_key' => 'setPublicKey', + 'type' => 'setType', + 'token' => 'setToken', 'access_information' => 'setAccessInformation', - 'last_commit' => 'setLastCommit', + 'last_commit' => 'setLastCommit', + 'build_config' => 'setBuildConfig', + // 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, ), - 'reference' => array( - 'type' => 'varchar', - 'length' => 250, + 'title' => array( + 'type' => 'varchar', + 'length' => 250, 'default' => null, ), - 'git_key' => array( - 'type' => 'text', - 'nullable' => true, - 'default' => null, + 'reference' => array( + 'type' => 'varchar', + 'length' => 250, + 'default' => null, ), - 'build_config' => array( - 'type' => 'text', + 'git_key' => array( + 'type' => 'text', 'nullable' => true, - 'default' => null, + 'default' => null, ), - 'type' => array( - 'type' => 'varchar', - 'length' => 50, + 'public_key' => 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, + ), + 'build_config' => array( + 'type' => 'text', + 'nullable' => true, + '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 BuildConfig / build_config. - * - * @return string - */ - public function getBuildConfig() + * Get the value of PublicKey / public_key. + * + * @return string + */ + public function getPublicKey() { - $rtn = $this->data['build_config']; + $rtn = $this->data['public_key']; + return $rtn; } /** - * Get the value of Type / type. - * - * @return string - */ + * 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 - */ + * Get the value of BuildConfig / build_config. + * + * @return string + */ + public function getBuildConfig() + { + $rtn = $this->data['build_config']; + + return $rtn; + } + + /** + * Set the value of Id / id. + * + * Must not be null. + * @param $value int + */ public function setId($value) { $this->_validateNotNull('Id', $value); @@ -261,17 +292,18 @@ 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); @@ -280,17 +312,18 @@ 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); @@ -299,15 +332,17 @@ 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); @@ -315,33 +350,36 @@ class ProjectBase extends Model if ($this->data['git_key'] === $value) { return; } + $this->data['git_key'] = $value; + $this->_setModified('git_key'); } /** - * Set the value of BuildConfig / build_config. - * - * @param $value string - */ - public function setBuildConfig($value) + * Set the value of PublicKey / public_key. + * + * @param $value string + */ + public function setPublicKey($value) { - $this->_validateString('BuildConfig', $value); + $this->_validateString('PublicKey', $value); - if ($this->data['build_config'] === $value) { + if ($this->data['public_key'] === $value) { return; } - $this->data['build_config'] = $value; - $this->_setModified('build_config'); + + $this->data['public_key'] = $value; + + $this->_setModified('public_key'); } /** - * Set the value of Type / type. - * - * Must not be null. - * - * @param $value string - */ + * Set the value of Type / type. + * + * Must not be null. + * @param $value string + */ public function setType($value) { $this->_validateNotNull('Type', $value); @@ -350,16 +388,17 @@ 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); @@ -367,15 +406,17 @@ 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); @@ -383,15 +424,17 @@ 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); @@ -399,10 +442,30 @@ class ProjectBase extends Model if ($this->data['last_commit'] === $value) { return; } + $this->data['last_commit'] = $value; + $this->_setModified('last_commit'); } + /** + * 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'); + } + /** * Get Build models by ProjectId for this Project. * @@ -415,11 +478,15 @@ 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); @@ -429,4 +496,7 @@ class ProjectBase extends Model { return Factory::getStore('Project', 'PHPCI')->getByTitle($value, $limit, $useConnection); } + + + } diff --git a/PHPCI/Model/Base/UserBase.php b/PHPCI/Model/Base/UserBase.php index 055eacce..f0b0e393 100644 --- a/PHPCI/Model/Base/UserBase.php +++ b/PHPCI/Model/Base/UserBase.php @@ -15,168 +15,173 @@ 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, ), - 'hash' => array( - 'type' => 'varchar', - 'length' => 250, + 'email' => array( + 'type' => 'varchar', + 'length' => 250, + 'default' => null, + ), + '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); @@ -185,17 +190,18 @@ 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); @@ -204,17 +210,18 @@ 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); @@ -223,17 +230,18 @@ 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); @@ -242,15 +250,17 @@ 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); @@ -258,15 +268,21 @@ 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); @@ -276,4 +292,7 @@ class UserBase extends Model { return Factory::getStore('User', 'PHPCI')->getByEmail($value, $useConnection); } + + + } diff --git a/PHPCI/Store/Base/BuildMetaStoreBase.php b/PHPCI/Store/Base/BuildMetaStoreBase.php index 1be8292a..4abd97a3 100644 --- a/PHPCI/Store/Base/BuildMetaStoreBase.php +++ b/PHPCI/Store/Base/BuildMetaStoreBase.php @@ -16,11 +16,9 @@ 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') { @@ -34,7 +32,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()) { @@ -42,6 +40,7 @@ class BuildMetaStoreBase extends Store return new BuildMeta($data); } } + return null; } @@ -52,13 +51,15 @@ 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()) { diff --git a/PHPCI/Store/Base/BuildStoreBase.php b/PHPCI/Store/Base/BuildStoreBase.php index 4b797375..b67d5f73 100644 --- a/PHPCI/Store/Base/BuildStoreBase.php +++ b/PHPCI/Store/Base/BuildStoreBase.php @@ -16,11 +16,9 @@ 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') { @@ -34,7 +32,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()) { @@ -42,6 +40,7 @@ class BuildStoreBase extends Store return new Build($data); } } + return null; } @@ -52,13 +51,15 @@ 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()) { @@ -82,13 +83,15 @@ 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()) { diff --git a/PHPCI/Store/Base/ProjectStoreBase.php b/PHPCI/Store/Base/ProjectStoreBase.php index 808f83c9..410a305e 100644 --- a/PHPCI/Store/Base/ProjectStoreBase.php +++ b/PHPCI/Store/Base/ProjectStoreBase.php @@ -16,11 +16,9 @@ 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') { @@ -34,7 +32,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()) { @@ -42,6 +40,7 @@ class ProjectStoreBase extends Store return new Project($data); } } + return null; } @@ -52,13 +51,15 @@ 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()) { diff --git a/PHPCI/Store/Base/UserStoreBase.php b/PHPCI/Store/Base/UserStoreBase.php index cafebea3..fd903d8e 100644 --- a/PHPCI/Store/Base/UserStoreBase.php +++ b/PHPCI/Store/Base/UserStoreBase.php @@ -16,11 +16,9 @@ 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') { @@ -34,7 +32,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()) { @@ -42,6 +40,7 @@ class UserStoreBase extends Store return new User($data); } } + return null; } @@ -52,7 +51,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()) { @@ -60,6 +59,7 @@ class UserStoreBase extends Store return new User($data); } } + return null; } }