00001 <?php
00002
00012 class CSERDuserPageviewLog extends CSERDModelBase {
00014 public static $ATTRIBUTES = array(
00015 'userPageviewLogId' => 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 'URL' => array(
00027 'type' => 'string',
00028 'default' => null
00029 ),
00030 'pageviewTime' => array(
00031 'nullable' => false,
00032 'commit' => SModel2::COMMIT_CHANGED,
00033 'type' => 'time',
00034 'default' => ''
00035 ),
00036 'user' => array(
00037 'commit' => SModel2::COMMIT_FOREIGN,
00038 'type' => 'CSERDuser'
00039 )
00040 );
00041
00051 public function __construct($constraints = null, $multi = false) {
00052 parent::__construct();
00053
00054 $this->registerAttributes(self::$ATTRIBUTES);
00055 $this->registerTableName('userPageviewLog');
00056 $this->registerPrimaryKey('userPageviewLogId', true);
00057
00058 if($constraints !== null)
00059 $this->populate($constraints, $multi);
00060 }
00061
00071 public static function getAttributesStatic() {
00072 return self::$ATTRIBUTES;
00073 }
00074
00080 public static function getTableNameStatic() {
00081 return 'userPageviewLog';
00082 }
00083
00095 public static function retrieve($constraints = array(), $checkOnly = false) {
00096 $list = self::getList($constraints, array(1), array(), $checkOnly);
00097 if(!$list || count($list) == 0)
00098 return $checkOnly ? false : null;
00099 else if($checkOnly)
00100 return $list > 0;
00101 else
00102 return $list[0];
00103 }
00104
00113 public static function exists($constraints = array()) {
00114 return self::retrieve($constraints, true);
00115 }
00116
00129 public static function retrieveMulti($constraints = array(), $checkOnly = false, $depth = 1) {
00130 $list = self::getListMulti($constraints, array(1), array(), $checkOnly, $depth);
00131 if(!$list || count($list) == 0)
00132 return $checkOnly ? false : null;
00133 else if($checkOnly)
00134 return $list > 0;
00135 else
00136 return $list[0];
00137 }
00138
00147 public static function existsMulti($constraints = array()) {
00148 return self::retrieveMulti($constraints, true);
00149 }
00150
00164 public static function getList($constraints = array(), $limit = array(), $order = array(), $count = false) {
00165 return parent::getListBase(self::getDBI(), $constraints, $limit, $order, $count, 'CSERDuserPageviewLog', true);
00166 }
00167
00183 public static function getListMulti($constraints = array(), $limit = array(), $order = array(), $count = false, $depth = 1) {
00184 return parent::getListBaseMulti(self::getDBI(), $constraints, $limit, $order, $count,
00185 'CSERDuserPageviewLog', true, $depth);
00186 }
00187
00188
00197 public function getParentUser() {
00198 return CSERDuser::retrieve(array('userId' => $this->userId));
00199 }
00200
00210 public function getParentUserMulti($depth = 1) {
00211 return CSERDuser::retrieveMulti(array('Base.userId' => $this->userId), false, $depth);
00212 }
00213 }
00214
00215 ?>