00001 <?php
00002
00012 class SDRSearchWord extends ModelBase {
00014 public static $ATTRIBUTES = array(
00015 'id' => array(
00016 'nullable' => false,
00017 'commit' => SModel2::COMMIT_NEVER,
00018 'type' => 'int'
00019 ),
00020 'word' => array(
00021 'nullable' => false,
00022 'type' => 'string'
00023 )
00024 );
00025
00034 public function __construct($constraints = null) {
00035 parent::__construct();
00036
00037 $this->registerAttributes(self::$ATTRIBUTES);
00038 $this->registerTableName('SDRSearchWord');
00039 $this->registerPrimaryKey('id', 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, 'SDRSearchWord', true);
00093 }
00094
00104 public static function getAttributesStatic() {
00105 return self::$ATTRIBUTES;
00106 }
00107
00113 public static function getTableNameStatic() {
00114 return 'SDRSearchWord';
00115 }
00116
00117
00134 public function listSDRSearchWordCounts($constraints = array(), $limit = array(), $order = array(), $count = false) {
00135 return parent::getListBase(self::getDBI(),
00136 array_merge($constraints, array('searchWordId' => $this->id)),
00137 $limit, $order, $count, 'SDRSearchWordCount', true);
00138 }
00139
00158 public function listSDRSearchWordCountsMulti($constraints = array(), $limit = array(), $order = array(), $count = false, $depth = 1) {
00159 return parent::getListBaseMulti(self::getDBI(),
00160 array_merge($constraints, array('Base.searchWordId' => $this->id)),
00161 $limit, $order, $count, 'SDRSearchWordCount', true, $depth);
00162 }
00163
00180 public function addSDRSearchWordCount($cserd, $field, $count) {
00181 $obj = new SDRSearchWordCount();
00182
00183 $obj->searchWordId = $this->id;
00184 if(is_object($cserd))
00185 $obj->cserd = $cserd;
00186 else
00187 $obj->cserdId = $cserd;
00188 if(is_object($field))
00189 $obj->field = $field;
00190 else
00191 $obj->fieldId = $field;
00192 $obj->count = $count;
00193
00194 if(!$obj->commit())
00195 return null;
00196
00197 return $obj;
00198 }
00199 }
00200
00201 ?>