General model / store cleanup
This commit is contained in:
parent
74d313862c
commit
31165a6bfa
|
@ -118,7 +118,7 @@ class BuildBase extends Model
|
||||||
'default' => null,
|
'default' => null,
|
||||||
),
|
),
|
||||||
'log' => array(
|
'log' => array(
|
||||||
'type' => 'text',
|
'type' => 'mediumtext',
|
||||||
'nullable' => true,
|
'nullable' => true,
|
||||||
'default' => null,
|
'default' => null,
|
||||||
),
|
),
|
||||||
|
|
|
@ -99,7 +99,7 @@ class BuildMetaBase extends Model
|
||||||
'default' => null,
|
'default' => null,
|
||||||
),
|
),
|
||||||
'meta_value' => array(
|
'meta_value' => array(
|
||||||
'type' => 'text',
|
'type' => 'mediumtext',
|
||||||
'default' => null,
|
'default' => null,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -106,6 +106,8 @@ class UserBase extends Model
|
||||||
public $indexes = array(
|
public $indexes = array(
|
||||||
'PRIMARY' => array('unique' => true, 'columns' => 'id'),
|
'PRIMARY' => array('unique' => true, 'columns' => 'id'),
|
||||||
'idx_email' => array('unique' => true, 'columns' => 'email'),
|
'idx_email' => array('unique' => true, 'columns' => 'email'),
|
||||||
|
'email' => array('unique' => true, 'columns' => 'email'),
|
||||||
|
'name' => array('unique' => true, 'columns' => 'name'),
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,24 +20,11 @@ class BuildMetaStoreBase extends Store
|
||||||
protected $modelName = '\PHPCI\Model\BuildMeta';
|
protected $modelName = '\PHPCI\Model\BuildMeta';
|
||||||
protected $primaryKey = 'id';
|
protected $primaryKey = 'id';
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a BuildMeta model by primary key.
|
|
||||||
* @param mixed $value
|
|
||||||
* @param string $useConnection
|
|
||||||
* @return \@appNamespace\Model\BuildMeta|null
|
|
||||||
*/
|
|
||||||
public function getByPrimaryKey($value, $useConnection = 'read')
|
public function getByPrimaryKey($value, $useConnection = 'read')
|
||||||
{
|
{
|
||||||
return $this->getById($value, $useConnection);
|
return $this->getById($value, $useConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a BuildMeta model by Id.
|
|
||||||
* @param mixed $value
|
|
||||||
* @param string $useConnection
|
|
||||||
* @throws HttpException
|
|
||||||
* @return \@appNamespace\Model\BuildMeta|null
|
|
||||||
*/
|
|
||||||
public function getById($value, $useConnection = 'read')
|
public function getById($value, $useConnection = 'read')
|
||||||
{
|
{
|
||||||
if (is_null($value)) {
|
if (is_null($value)) {
|
||||||
|
@ -57,14 +44,6 @@ class BuildMetaStoreBase extends Store
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an array of BuildMeta models by ProjectId.
|
|
||||||
* @param mixed $value
|
|
||||||
* @param int $limit
|
|
||||||
* @param string $useConnection
|
|
||||||
* @throws HttpException
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getByProjectId($value, $limit = 1000, $useConnection = 'read')
|
public function getByProjectId($value, $limit = 1000, $useConnection = 'read')
|
||||||
{
|
{
|
||||||
if (is_null($value)) {
|
if (is_null($value)) {
|
||||||
|
@ -93,14 +72,6 @@ class BuildMetaStoreBase extends Store
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an array of BuildMeta models by BuildId.
|
|
||||||
* @param mixed $value
|
|
||||||
* @param int $limit
|
|
||||||
* @param string $useConnection
|
|
||||||
* @throws HttpException
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getByBuildId($value, $limit = 1000, $useConnection = 'read')
|
public function getByBuildId($value, $limit = 1000, $useConnection = 'read')
|
||||||
{
|
{
|
||||||
if (is_null($value)) {
|
if (is_null($value)) {
|
||||||
|
|
|
@ -20,24 +20,11 @@ class BuildStoreBase extends Store
|
||||||
protected $modelName = '\PHPCI\Model\Build';
|
protected $modelName = '\PHPCI\Model\Build';
|
||||||
protected $primaryKey = 'id';
|
protected $primaryKey = 'id';
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a Build model by primary key.
|
|
||||||
* @param mixed $value
|
|
||||||
* @param string $useConnection
|
|
||||||
* @return \@appNamespace\Model\Build|null
|
|
||||||
*/
|
|
||||||
public function getByPrimaryKey($value, $useConnection = 'read')
|
public function getByPrimaryKey($value, $useConnection = 'read')
|
||||||
{
|
{
|
||||||
return $this->getById($value, $useConnection);
|
return $this->getById($value, $useConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a Build model by Id.
|
|
||||||
* @param mixed $value
|
|
||||||
* @param string $useConnection
|
|
||||||
* @throws HttpException
|
|
||||||
* @return \@appNamespace\Model\Build|null
|
|
||||||
*/
|
|
||||||
public function getById($value, $useConnection = 'read')
|
public function getById($value, $useConnection = 'read')
|
||||||
{
|
{
|
||||||
if (is_null($value)) {
|
if (is_null($value)) {
|
||||||
|
@ -57,14 +44,6 @@ class BuildStoreBase extends Store
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an array of Build models by ProjectId.
|
|
||||||
* @param mixed $value
|
|
||||||
* @param int $limit
|
|
||||||
* @param string $useConnection
|
|
||||||
* @throws HttpException
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getByProjectId($value, $limit = 1000, $useConnection = 'read')
|
public function getByProjectId($value, $limit = 1000, $useConnection = 'read')
|
||||||
{
|
{
|
||||||
if (is_null($value)) {
|
if (is_null($value)) {
|
||||||
|
@ -93,14 +72,6 @@ class BuildStoreBase extends Store
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an array of Build models by Status.
|
|
||||||
* @param mixed $value
|
|
||||||
* @param int $limit
|
|
||||||
* @param string $useConnection
|
|
||||||
* @throws HttpException
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getByStatus($value, $limit = 1000, $useConnection = 'read')
|
public function getByStatus($value, $limit = 1000, $useConnection = 'read')
|
||||||
{
|
{
|
||||||
if (is_null($value)) {
|
if (is_null($value)) {
|
||||||
|
|
|
@ -20,24 +20,11 @@ class UserStoreBase extends Store
|
||||||
protected $modelName = '\PHPCI\Model\User';
|
protected $modelName = '\PHPCI\Model\User';
|
||||||
protected $primaryKey = 'id';
|
protected $primaryKey = 'id';
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a User model by primary key.
|
|
||||||
* @param mixed $value
|
|
||||||
* @param string $useConnection
|
|
||||||
* @return \@appNamespace\Model\User|null
|
|
||||||
*/
|
|
||||||
public function getByPrimaryKey($value, $useConnection = 'read')
|
public function getByPrimaryKey($value, $useConnection = 'read')
|
||||||
{
|
{
|
||||||
return $this->getById($value, $useConnection);
|
return $this->getById($value, $useConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a User model by Id.
|
|
||||||
* @param mixed $value
|
|
||||||
* @param string $useConnection
|
|
||||||
* @throws HttpException
|
|
||||||
* @return \@appNamespace\Model\User|null
|
|
||||||
*/
|
|
||||||
public function getById($value, $useConnection = 'read')
|
public function getById($value, $useConnection = 'read')
|
||||||
{
|
{
|
||||||
if (is_null($value)) {
|
if (is_null($value)) {
|
||||||
|
@ -57,13 +44,6 @@ class UserStoreBase extends Store
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a User model by Email.
|
|
||||||
* @param string $value
|
|
||||||
* @param string $useConnection
|
|
||||||
* @throws HttpException
|
|
||||||
* @return \@appNamespace\Model\User|null
|
|
||||||
*/
|
|
||||||
public function getByEmail($value, $useConnection = 'read')
|
public function getByEmail($value, $useConnection = 'read')
|
||||||
{
|
{
|
||||||
if (is_null($value)) {
|
if (is_null($value)) {
|
||||||
|
@ -82,23 +62,16 @@ class UserStoreBase extends Store
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getByName($value, $useConnection = 'read')
|
||||||
* Returns a User model by Email.
|
|
||||||
* @param string $value
|
|
||||||
* @param string $useConnection
|
|
||||||
* @throws HttpException
|
|
||||||
* @return \@appNamespace\Model\User|null
|
|
||||||
*/
|
|
||||||
public function getByLoginOrEmail($value, $useConnection = 'read')
|
|
||||||
{
|
{
|
||||||
if (is_null($value)) {
|
if (is_null($value)) {
|
||||||
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
|
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = 'SELECT * FROM `user` WHERE `name` = :value OR `email` = :value LIMIT 1';
|
$query = 'SELECT * FROM `user` WHERE `name` = :name LIMIT 1';
|
||||||
$stmt = Database::getConnection($useConnection)->prepare($query);
|
$stmt = Database::getConnection($useConnection)->prepare($query);
|
||||||
$stmt->bindValue(':value', $value);
|
$stmt->bindValue(':name', $value);
|
||||||
|
|
||||||
if ($stmt->execute()) {
|
if ($stmt->execute()) {
|
||||||
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||||
|
|
Loading…
Reference in a new issue