2013-05-10 17:25:51 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* User base model for table: user
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace PHPCI\Model\Base;
|
2013-05-16 16:40:40 +02:00
|
|
|
|
2014-02-25 17:43:06 +01:00
|
|
|
use PHPCI\Model;
|
2013-10-10 02:01:06 +02:00
|
|
|
use b8\Store\Factory;
|
2013-05-10 17:25:51 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* User Base Model
|
|
|
|
*/
|
|
|
|
class UserBase extends Model
|
|
|
|
{
|
2013-05-16 16:40:40 +02:00
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
public static $sleepable = array();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $tableName = 'user';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $modelName = 'User';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $data = array(
|
|
|
|
'id' => null,
|
|
|
|
'email' => null,
|
|
|
|
'hash' => null,
|
|
|
|
'is_admin' => null,
|
|
|
|
'name' => null,
|
2013-10-10 02:01:06 +02:00
|
|
|
);
|
2013-05-16 16:40:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $getters = array(
|
2013-10-10 02:01:06 +02:00
|
|
|
// Direct property getters:
|
2013-05-16 16:40:40 +02:00
|
|
|
'id' => 'getId',
|
|
|
|
'email' => 'getEmail',
|
|
|
|
'hash' => 'getHash',
|
|
|
|
'is_admin' => 'getIsAdmin',
|
|
|
|
'name' => 'getName',
|
2013-10-10 02:01:06 +02:00
|
|
|
|
|
|
|
// Foreign key getters:
|
|
|
|
);
|
2013-05-16 16:40:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $setters = array(
|
2013-10-10 02:01:06 +02:00
|
|
|
// Direct property setters:
|
2013-05-16 16:40:40 +02:00
|
|
|
'id' => 'setId',
|
|
|
|
'email' => 'setEmail',
|
|
|
|
'hash' => 'setHash',
|
|
|
|
'is_admin' => 'setIsAdmin',
|
|
|
|
'name' => 'setName',
|
2013-10-10 02:01:06 +02:00
|
|
|
|
|
|
|
// Foreign key setters:
|
|
|
|
);
|
2013-05-16 16:40:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
public $columns = array(
|
|
|
|
'id' => array(
|
|
|
|
'type' => 'int',
|
2013-10-10 02:01:06 +02:00
|
|
|
'length' => 11,
|
2013-05-16 16:40:40 +02:00
|
|
|
'primary_key' => true,
|
|
|
|
'auto_increment' => true,
|
2013-10-08 08:45:20 +02:00
|
|
|
'default' => null,
|
2013-10-10 02:01:06 +02:00
|
|
|
),
|
2013-05-16 16:40:40 +02:00
|
|
|
'email' => array(
|
|
|
|
'type' => 'varchar',
|
2013-10-10 02:01:06 +02:00
|
|
|
'length' => 250,
|
2014-02-25 17:43:06 +01:00
|
|
|
'default' => null,
|
2013-10-10 02:01:06 +02:00
|
|
|
),
|
2013-05-16 16:40:40 +02:00
|
|
|
'hash' => array(
|
|
|
|
'type' => 'varchar',
|
2013-10-10 02:01:06 +02:00
|
|
|
'length' => 250,
|
2014-02-25 17:43:06 +01:00
|
|
|
'default' => null,
|
2013-10-10 02:01:06 +02:00
|
|
|
),
|
2013-05-16 16:40:40 +02:00
|
|
|
'is_admin' => array(
|
|
|
|
'type' => 'tinyint',
|
2013-10-10 02:01:06 +02:00
|
|
|
'length' => 1,
|
2014-02-25 17:43:06 +01:00
|
|
|
'default' => null,
|
2013-10-10 02:01:06 +02:00
|
|
|
),
|
2013-05-16 16:40:40 +02:00
|
|
|
'name' => array(
|
|
|
|
'type' => 'varchar',
|
2013-10-10 02:01:06 +02:00
|
|
|
'length' => 250,
|
2013-10-08 10:00:22 +02:00
|
|
|
'nullable' => true,
|
|
|
|
'default' => null,
|
2013-10-10 02:01:06 +02:00
|
|
|
),
|
|
|
|
);
|
2013-05-16 16:40:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
public $indexes = array(
|
|
|
|
'PRIMARY' => array('unique' => true, 'columns' => 'id'),
|
|
|
|
'idx_email' => array('unique' => true, 'columns' => 'email'),
|
2013-10-10 02:01:06 +02:00
|
|
|
);
|
2013-05-16 16:40:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
public $foreignKeys = array(
|
2013-10-10 02:01:06 +02:00
|
|
|
);
|
2013-05-16 16:40:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the value of Id / id.
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getId()
|
|
|
|
{
|
2013-05-16 16:53:00 +02:00
|
|
|
$rtn = $this->data['id'];
|
2013-05-16 16:40:40 +02:00
|
|
|
|
|
|
|
return $rtn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the value of Email / email.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getEmail()
|
|
|
|
{
|
2013-05-16 16:53:00 +02:00
|
|
|
$rtn = $this->data['email'];
|
2013-05-16 16:40:40 +02:00
|
|
|
|
|
|
|
return $rtn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the value of Hash / hash.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getHash()
|
|
|
|
{
|
2013-05-16 16:53:00 +02:00
|
|
|
$rtn = $this->data['hash'];
|
2013-05-16 16:40:40 +02:00
|
|
|
|
|
|
|
return $rtn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the value of IsAdmin / is_admin.
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getIsAdmin()
|
|
|
|
{
|
2013-05-16 16:53:00 +02:00
|
|
|
$rtn = $this->data['is_admin'];
|
2013-05-16 16:40:40 +02:00
|
|
|
|
|
|
|
return $rtn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the value of Name / name.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getName()
|
|
|
|
{
|
2013-05-16 16:53:00 +02:00
|
|
|
$rtn = $this->data['name'];
|
2013-05-16 16:40:40 +02:00
|
|
|
|
|
|
|
return $rtn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the value of Id / id.
|
|
|
|
*
|
|
|
|
* Must not be null.
|
|
|
|
* @param $value int
|
|
|
|
*/
|
|
|
|
public function setId($value)
|
|
|
|
{
|
|
|
|
$this->_validateNotNull('Id', $value);
|
|
|
|
$this->_validateInt('Id', $value);
|
2013-10-10 02:01:06 +02:00
|
|
|
|
2013-10-08 08:45:20 +02:00
|
|
|
if ($this->data['id'] === $value) {
|
2013-05-16 16:40:40 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-16 16:53:00 +02:00
|
|
|
$this->data['id'] = $value;
|
2013-05-16 16:40:40 +02:00
|
|
|
|
|
|
|
$this->_setModified('id');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the value of Email / email.
|
|
|
|
*
|
|
|
|
* Must not be null.
|
|
|
|
* @param $value string
|
|
|
|
*/
|
|
|
|
public function setEmail($value)
|
|
|
|
{
|
|
|
|
$this->_validateNotNull('Email', $value);
|
|
|
|
$this->_validateString('Email', $value);
|
2013-10-10 02:01:06 +02:00
|
|
|
|
2013-10-08 08:45:20 +02:00
|
|
|
if ($this->data['email'] === $value) {
|
2013-05-16 16:40:40 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-16 16:53:00 +02:00
|
|
|
$this->data['email'] = $value;
|
2013-05-16 16:40:40 +02:00
|
|
|
|
|
|
|
$this->_setModified('email');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the value of Hash / hash.
|
|
|
|
*
|
|
|
|
* Must not be null.
|
|
|
|
* @param $value string
|
|
|
|
*/
|
|
|
|
public function setHash($value)
|
|
|
|
{
|
|
|
|
$this->_validateNotNull('Hash', $value);
|
|
|
|
$this->_validateString('Hash', $value);
|
2013-10-10 02:01:06 +02:00
|
|
|
|
2013-10-08 08:45:20 +02:00
|
|
|
if ($this->data['hash'] === $value) {
|
2013-05-16 16:40:40 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-16 16:53:00 +02:00
|
|
|
$this->data['hash'] = $value;
|
2013-05-16 16:40:40 +02:00
|
|
|
|
|
|
|
$this->_setModified('hash');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the value of IsAdmin / is_admin.
|
|
|
|
*
|
|
|
|
* Must not be null.
|
|
|
|
* @param $value int
|
|
|
|
*/
|
|
|
|
public function setIsAdmin($value)
|
|
|
|
{
|
|
|
|
$this->_validateNotNull('IsAdmin', $value);
|
|
|
|
$this->_validateInt('IsAdmin', $value);
|
2013-10-10 02:01:06 +02:00
|
|
|
|
2013-10-08 08:45:20 +02:00
|
|
|
if ($this->data['is_admin'] === $value) {
|
2013-05-16 16:40:40 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-16 16:53:00 +02:00
|
|
|
$this->data['is_admin'] = $value;
|
2013-05-16 16:40:40 +02:00
|
|
|
|
|
|
|
$this->_setModified('is_admin');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the value of Name / name.
|
|
|
|
*
|
|
|
|
* @param $value string
|
|
|
|
*/
|
|
|
|
public function setName($value)
|
|
|
|
{
|
|
|
|
$this->_validateString('Name', $value);
|
2013-10-10 02:01:06 +02:00
|
|
|
|
2013-10-08 08:45:20 +02:00
|
|
|
if ($this->data['name'] === $value) {
|
2013-05-16 16:40:40 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-16 16:53:00 +02:00
|
|
|
$this->data['name'] = $value;
|
2013-05-16 16:40:40 +02:00
|
|
|
|
|
|
|
$this->_setModified('name');
|
|
|
|
}
|
2014-02-25 17:43:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getByEmail($value, $useConnection = 'read')
|
|
|
|
{
|
|
|
|
return Factory::getStore('User', 'PHPCI')->getByEmail($value, $useConnection);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-10 17:25:51 +02:00
|
|
|
}
|