00001 <?php
00002
00012 class SDRSearchWordCount extends ModelBase {
00014 public static $ATTRIBUTES = array(
00015 'searchWordId' => array(
00016 'nullable' => false,
00017 'commit' => SModel2::COMMIT_CHANGED,
00018 'type' => 'int',
00019 'foreign' => array('table' => 'SDRSearchWord', 'on' => 'id', 'object' => 'searchWord')
00020 ),
00021 'cserdId' => array(
00022 'nullable' => false,
00023 'commit' => SModel2::COMMIT_CHANGED,
00024 'type' => 'int',
00025 'foreign' => array('table' => 'SDRResource', 'on' => 'cserdId', 'object' => 'cserd')
00026 ),
00027 'fieldId' => array(
00028 'nullable' => false,
00029 'commit' => SModel2::COMMIT_CHANGED,
00030 'type' => 'int',
00031 'foreign' => array('table' => 'SDRField', 'on' => 'id', 'object' => 'field')
00032 ),
00033 'count' => array(
00034 'nullable' => false,
00035 'type' => 'int'
00036 ),
00037 'searchWord' => array(
00038 'commit' => SModel2::COMMIT_FOREIGN,
00039 'type' => 'SDRSearchWord'
00040 ),
00041 'cserd' => array(
00042 'commit' => SModel2::COMMIT_FOREIGN,
00043 'type' => 'SDRResource'
00044 ),
00045 'field' => array(
00046 'commit' => SModel2::COMMIT_FOREIGN,
00047 'type' => 'SDRField'
00048 )
00049 );
00050
00060 public function __construct($constraints = null, $multi = false) {
00061 parent::__construct();
00062
00063 $this->registerAttributes(self::$ATTRIBUTES);
00064 $this->registerTableName('SDRSearchWordCount');
00065 $this->registerPrimaryKey(array('searchWordId', 'cserdId', 'fieldId'), false);
00066
00067 if($constraints !== null)
00068 $this->populate($constraints, $multi);
00069 }
00070
00080 public static function getAttributesStatic() {
00081 return self::$ATTRIBUTES;
00082 }
00083
00089 public static function getTableNameStatic() {
00090 return 'SDRSearchWordCount';
00091 }
00092
00104 public static function retrieve($constraints = array(), $checkOnly = false) {
00105 $list = self::getList($constraints, array(1), array(), $checkOnly);
00106 if(!$list || count($list) == 0)
00107 return $checkOnly ? false : null;
00108 else if($checkOnly)
00109 return $list > 0;
00110 else
00111 return $list[0];
00112 }
00113
00122 public static function exists($constraints = array()) {
00123 return self::retrieve($constraints, true);
00124 }
00125
00138 public static function retrieveMulti($constraints = array(), $checkOnly = false, $depth = 1) {
00139 $list = self::getListMulti($constraints, array(1), array(), $checkOnly, $depth);
00140 if(!$list || count($list) == 0)
00141 return $checkOnly ? false : null;
00142 else if($checkOnly)
00143 return $list > 0;
00144 else
00145 return $list[0];
00146 }
00147
00156 public static function existsMulti($constraints = array()) {
00157 return self::retrieveMulti($constraints, true);
00158 }
00159
00173 public static function getList($constraints = array(), $limit = array(), $order = array(), $count = false) {
00174 return parent::getListBase(self::getDBI(), $constraints, $limit, $order, $count, 'SDRSearchWordCount', true);
00175 }
00176
00192 public static function getListMulti($constraints = array(), $limit = array(), $order = array(), $count = false, $depth = 1) {
00193 return parent::getListBaseMulti(self::getDBI(), $constraints, $limit, $order, $count,
00194 'SDRSearchWordCount', true, $depth);
00195 }
00196
00197
00206 public function getParentSearchWord() {
00207 return SDRSearchWord::retrieve(array('id' => $this->searchWordId));
00208 }
00209
00219 public function getParentSearchWordMulti($depth = 1) {
00220 return SDRSearchWord::retrieveMulti(array('Base.id' => $this->searchWordId), false, $depth);
00221 }
00222
00231 public function getParentCserd() {
00232 return SDRResource::retrieve(array('cserdId' => $this->cserdId));
00233 }
00234
00244 public function getParentCserdMulti($depth = 1) {
00245 return SDRResource::retrieveMulti(array('Base.cserdId' => $this->cserdId), false, $depth);
00246 }
00247
00256 public function getParentField() {
00257 return SDRField::retrieve(array('id' => $this->fieldId));
00258 }
00259
00269 public function getParentFieldMulti($depth = 1) {
00270 return SDRField::retrieveMulti(array('Base.id' => $this->fieldId), false, $depth);
00271 }
00272 }
00273
00274 ?>