00001 <?php
00002
00012 class SDRVersionFieldValue extends ModelBase {
00014 public static $ATTRIBUTES = array(
00015 'versionId' => array(
00016 'nullable' => false,
00017 'commit' => SModel2::COMMIT_CHANGED,
00018 'type' => 'int',
00019 'foreign' => array('table' => 'SDRVersion', 'on' => 'id', 'object' => 'version')
00020 ),
00021 'fieldId' => array(
00022 'nullable' => false,
00023 'commit' => SModel2::COMMIT_CHANGED,
00024 'type' => 'int',
00025 'foreign' => array('table' => 'SDRField', 'on' => 'id', 'object' => 'field')
00026 ),
00027 'valueId' => array(
00028 'nullable' => false,
00029 'commit' => SModel2::COMMIT_CHANGED,
00030 'type' => 'int',
00031 'foreign' => array('table' => 'SDRValue', 'on' => 'id', 'object' => 'value')
00032 ),
00033 'version' => array(
00034 'commit' => SModel2::COMMIT_FOREIGN,
00035 'type' => 'SDRVersion'
00036 ),
00037 'field' => array(
00038 'commit' => SModel2::COMMIT_FOREIGN,
00039 'type' => 'SDRField'
00040 ),
00041 'value' => array(
00042 'commit' => SModel2::COMMIT_FOREIGN,
00043 'type' => 'SDRValue'
00044 )
00045 );
00046
00056 public function __construct($constraints = null, $multi = false) {
00057 parent::__construct();
00058
00059 $this->registerAttributes(self::$ATTRIBUTES);
00060 $this->registerTableName('SDRVersionFieldValue');
00061 $this->registerPrimaryKey(array('versionId', 'fieldId', 'valueId'), false);
00062
00063 if($constraints !== null)
00064 $this->populate($constraints, $multi);
00065 }
00066
00076 public static function getAttributesStatic() {
00077 return self::$ATTRIBUTES;
00078 }
00079
00085 public static function getTableNameStatic() {
00086 return 'SDRVersionFieldValue';
00087 }
00088
00100 public static function retrieve($constraints = array(), $checkOnly = false) {
00101 $list = self::getList($constraints, array(1), array(), $checkOnly);
00102 if(!$list || count($list) == 0)
00103 return $checkOnly ? false : null;
00104 else if($checkOnly)
00105 return $list > 0;
00106 else
00107 return $list[0];
00108 }
00109
00118 public static function exists($constraints = array()) {
00119 return self::retrieve($constraints, true);
00120 }
00121
00134 public static function retrieveMulti($constraints = array(), $checkOnly = false, $depth = 1) {
00135 $list = self::getListMulti($constraints, array(1), array(), $checkOnly, $depth);
00136 if(!$list || count($list) == 0)
00137 return $checkOnly ? false : null;
00138 else if($checkOnly)
00139 return $list > 0;
00140 else
00141 return $list[0];
00142 }
00143
00152 public static function existsMulti($constraints = array()) {
00153 return self::retrieveMulti($constraints, true);
00154 }
00155
00169 public static function getList($constraints = array(), $limit = array(), $order = array(), $count = false) {
00170 return parent::getListBase(self::getDBI(), $constraints, $limit, $order, $count, 'SDRVersionFieldValue', true);
00171 }
00172
00188 public static function getListMulti($constraints = array(), $limit = array(), $order = array(), $count = false, $depth = 1) {
00189 return parent::getListBaseMulti(self::getDBI(), $constraints, $limit, $order, $count,
00190 'SDRVersionFieldValue', true, $depth);
00191 }
00192
00193
00202 public function getParentVersion() {
00203 return SDRVersion::retrieve(array('id' => $this->versionId));
00204 }
00205
00215 public function getParentVersionMulti($depth = 1) {
00216 return SDRVersion::retrieveMulti(array('Base.id' => $this->versionId), false, $depth);
00217 }
00218
00227 public function getParentField() {
00228 return SDRField::retrieve(array('id' => $this->fieldId));
00229 }
00230
00240 public function getParentFieldMulti($depth = 1) {
00241 return SDRField::retrieveMulti(array('Base.id' => $this->fieldId), false, $depth);
00242 }
00243
00252 public function getParentValue() {
00253 return SDRValue::retrieve(array('id' => $this->valueId));
00254 }
00255
00265 public function getParentValueMulti($depth = 1) {
00266 return SDRValue::retrieveMulti(array('Base.id' => $this->valueId), false, $depth);
00267 }
00268 }
00269
00270 ?>