00001 <?php
00002
00012 class CSERDdetail extends CSERDModelBase {
00014 public static $ATTRIBUTES = array(
00015 'detailId' => array(
00016 'nullable' => false,
00017 'commit' => SModel2::COMMIT_NEVER,
00018 'type' => 'int'
00019 ),
00020 'name' => array(
00021 'type' => 'string',
00022 'default' => null
00023 )
00024 );
00025
00034 public function __construct($constraints = null) {
00035 parent::__construct();
00036
00037 $this->registerAttributes(self::$ATTRIBUTES);
00038 $this->registerTableName('detail');
00039 $this->registerPrimaryKey('detailId', true);
00040
00041 if($constraints !== null)
00042 $this->populate($constraints);
00043 }
00044
00056 public static function retrieve($constraints = array(), $checkOnly = false) {
00057 $list = self::getList($constraints, array(1), array(), $checkOnly);
00058 if(!$list || count($list) == 0)
00059 return $checkOnly ? false : null;
00060 else if($checkOnly)
00061 return $list > 0;
00062 else
00063 return $list[0];
00064 }
00065
00074 public static function exists($constraints = array()) {
00075 return self::retrieve($constraints, true);
00076 }
00077
00091 public static function getList($constraints = array(), $limit = array(), $order = array(), $count = false) {
00092 return parent::getListBase(self::getDBI(), $constraints, $limit, $order, $count, 'CSERDdetail', true);
00093 }
00094
00104 public static function getAttributesStatic() {
00105 return self::$ATTRIBUTES;
00106 }
00107
00113 public static function getTableNameStatic() {
00114 return 'detail';
00115 }
00116
00117
00134 public function listuserDetails($constraints = array(), $limit = array(), $order = array(), $count = false) {
00135 return parent::getListBase(self::getDBI(),
00136 array_merge($constraints, array('detailId' => $this->detailId)),
00137 $limit, $order, $count, 'CSERDuserDetail', true);
00138 }
00139
00158 public function listuserDetailsMulti($constraints = array(), $limit = array(), $order = array(), $count = false, $depth = 1) {
00159 return parent::getListBaseMulti(self::getDBI(),
00160 array_merge($constraints, array('Base.detailId' => $this->detailId)),
00161 $limit, $order, $count, 'CSERDuserDetail', true, $depth);
00162 }
00163
00179 public function adduserDetail($user, $data = null) {
00180 $obj = new CSERDuserDetail();
00181
00182 $obj->detailId = $this->detailId;
00183 if(is_object($user))
00184 $obj->user = $user;
00185 else
00186 $obj->userId = $user;
00187 if($data != '')
00188 $obj->data = $data;
00189
00190 if(!$obj->commit())
00191 return null;
00192
00193 return $obj;
00194 }
00195 }
00196
00197 ?>