00001 <?php
00002
00012 class CSERDuserLoginLog extends CSERDModelBase {
00014 public static $ATTRIBUTES = array(
00015 'userLoginLogId' => array(
00016 'nullable' => false,
00017 'commit' => SModel2::COMMIT_NEVER,
00018 'type' => 'int'
00019 ),
00020 'userId' => array(
00021 'nullable' => false,
00022 'commit' => SModel2::COMMIT_FIRST,
00023 'type' => 'int',
00024 'foreign' => array('table' => 'user', 'on' => 'userId', 'object' => 'user')
00025 ),
00026 'loginTime' => array(
00027 'nullable' => false,
00028 'commit' => SModel2::COMMIT_CHANGED,
00029 'type' => 'time',
00030 'default' => ''
00031 ),
00032 'user' => array(
00033 'commit' => SModel2::COMMIT_FOREIGN,
00034 'type' => 'CSERDuser'
00035 )
00036 );
00037
00047 public function __construct($constraints = null, $multi = false) {
00048 parent::__construct();
00049
00050 $this->registerAttributes(self::$ATTRIBUTES);
00051 $this->registerTableName('userLoginLog');
00052 $this->registerPrimaryKey('userLoginLogId', true);
00053
00054 if($constraints !== null)
00055 $this->populate($constraints, $multi);
00056 }
00057
00067 public static function getAttributesStatic() {
00068 return self::$ATTRIBUTES;
00069 }
00070
00076 public static function getTableNameStatic() {
00077 return 'userLoginLog';
00078 }
00079
00091 public static function retrieve($constraints = array(), $checkOnly = false) {
00092 $list = self::getList($constraints, array(1), array(), $checkOnly);
00093 if(!$list || count($list) == 0)
00094 return $checkOnly ? false : null;
00095 else if($checkOnly)
00096 return $list > 0;
00097 else
00098 return $list[0];
00099 }
00100
00109 public static function exists($constraints = array()) {
00110 return self::retrieve($constraints, true);
00111 }
00112
00125 public static function retrieveMulti($constraints = array(), $checkOnly = false, $depth = 1) {
00126 $list = self::getListMulti($constraints, array(1), array(), $checkOnly, $depth);
00127 if(!$list || count($list) == 0)
00128 return $checkOnly ? false : null;
00129 else if($checkOnly)
00130 return $list > 0;
00131 else
00132 return $list[0];
00133 }
00134
00143 public static function existsMulti($constraints = array()) {
00144 return self::retrieveMulti($constraints, true);
00145 }
00146
00160 public static function getList($constraints = array(), $limit = array(), $order = array(), $count = false) {
00161 return parent::getListBase(self::getDBI(), $constraints, $limit, $order, $count, 'CSERDuserLoginLog', true);
00162 }
00163
00179 public static function getListMulti($constraints = array(), $limit = array(), $order = array(), $count = false, $depth = 1) {
00180 return parent::getListBaseMulti(self::getDBI(), $constraints, $limit, $order, $count,
00181 'CSERDuserLoginLog', true, $depth);
00182 }
00183
00184
00193 public function getParentUser() {
00194 return CSERDuser::retrieve(array('userId' => $this->userId));
00195 }
00196
00206 public function getParentUserMulti($depth = 1) {
00207 return CSERDuser::retrieveMulti(array('Base.userId' => $this->userId), false, $depth);
00208 }
00209 }
00210
00211 ?>