00001 <?php
00002
00012 class CSERDuserDetail extends CSERDModelBase {
00014 public static $ATTRIBUTES = array(
00015 'detailId' => array(
00016 'commit' => SModel2::COMMIT_FIRST,
00017 'type' => 'int',
00018 'default' => null,
00019 'foreign' => array('table' => 'detail', 'on' => 'detailId', 'object' => 'detail')
00020 ),
00021 'userId' => array(
00022 'commit' => SModel2::COMMIT_FIRST,
00023 'type' => 'int',
00024 'default' => null,
00025 'foreign' => array('table' => 'user', 'on' => 'userId', 'object' => 'user')
00026 ),
00027 'data' => array(
00028 'type' => 'string',
00029 'default' => null
00030 ),
00031 'user' => array(
00032 'commit' => SModel2::COMMIT_FOREIGN,
00033 'type' => 'CSERDuser'
00034 ),
00035 'detail' => array(
00036 'commit' => SModel2::COMMIT_FOREIGN,
00037 'type' => 'CSERDdetail'
00038 )
00039 );
00040
00050 public function __construct($constraints = null, $multi = false) {
00051 parent::__construct();
00052
00053 $this->registerAttributes(self::$ATTRIBUTES);
00054 $this->registerTableName('userDetail');
00055
00056 if($constraints !== null)
00057 $this->populate($constraints, $multi);
00058 }
00059
00069 public static function getAttributesStatic() {
00070 return self::$ATTRIBUTES;
00071 }
00072
00078 public static function getTableNameStatic() {
00079 return 'userDetail';
00080 }
00081
00093 public static function retrieve($constraints = array(), $checkOnly = false) {
00094 $list = self::getList($constraints, array(1), array(), $checkOnly);
00095 if(!$list || count($list) == 0)
00096 return $checkOnly ? false : null;
00097 else if($checkOnly)
00098 return $list > 0;
00099 else
00100 return $list[0];
00101 }
00102
00111 public static function exists($constraints = array()) {
00112 return self::retrieve($constraints, true);
00113 }
00114
00127 public static function retrieveMulti($constraints = array(), $checkOnly = false, $depth = 1) {
00128 $list = self::getListMulti($constraints, array(1), array(), $checkOnly, $depth);
00129 if(!$list || count($list) == 0)
00130 return $checkOnly ? false : null;
00131 else if($checkOnly)
00132 return $list > 0;
00133 else
00134 return $list[0];
00135 }
00136
00145 public static function existsMulti($constraints = array()) {
00146 return self::retrieveMulti($constraints, true);
00147 }
00148
00162 public static function getList($constraints = array(), $limit = array(), $order = array(), $count = false) {
00163 return parent::getListBase(self::getDBI(), $constraints, $limit, $order, $count, 'CSERDuserDetail', true);
00164 }
00165
00181 public static function getListMulti($constraints = array(), $limit = array(), $order = array(), $count = false, $depth = 1) {
00182 return parent::getListBaseMulti(self::getDBI(), $constraints, $limit, $order, $count,
00183 'CSERDuserDetail', true, $depth);
00184 }
00185
00186
00195 public function getParentDetail() {
00196 return CSERDdetail::retrieve(array('detailId' => $this->detailId));
00197 }
00198
00208 public function getParentDetailMulti($depth = 1) {
00209 return CSERDdetail::retrieveMulti(array('Base.detailId' => $this->detailId), false, $depth);
00210 }
00211
00220 public function getParentUser() {
00221 return CSERDuser::retrieve(array('userId' => $this->userId));
00222 }
00223
00233 public function getParentUserMulti($depth = 1) {
00234 return CSERDuser::retrieveMulti(array('Base.userId' => $this->userId), false, $depth);
00235 }
00236 }
00237
00238 ?>