00001 <?php
00002
00012 class SDRDateValue extends ModelBase {
00014 public static $ATTRIBUTES = array(
00015 'valueId' => array(
00016 'nullable' => false,
00017 'commit' => SModel2::COMMIT_CHANGED,
00018 'type' => 'int',
00019 'foreign' => array('table' => 'SDRValue', 'on' => 'id', 'object' => 'value')
00020 ),
00021 'entry' => array(
00022 'nullable' => false,
00023 'commit' => SModel2::COMMIT_CHANGED,
00024 'type' => 'time',
00025 'default' => ''
00026 ),
00027 'value' => array(
00028 'commit' => SModel2::COMMIT_FOREIGN,
00029 'type' => 'SDRValue'
00030 )
00031 );
00032
00042 public function __construct($constraints = null, $multi = false) {
00043 parent::__construct();
00044
00045 $this->registerAttributes(self::$ATTRIBUTES);
00046 $this->registerTableName('SDRDateValue');
00047 $this->registerPrimaryKey('valueId');
00048
00049 if($constraints !== null)
00050 $this->populate($constraints, $multi);
00051 }
00052
00062 public static function getAttributesStatic() {
00063 return self::$ATTRIBUTES;
00064 }
00065
00071 public static function getTableNameStatic() {
00072 return 'SDRDateValue';
00073 }
00074
00086 public static function retrieve($constraints = array(), $checkOnly = false) {
00087 $list = self::getList($constraints, array(1), array(), $checkOnly);
00088 if(!$list || count($list) == 0)
00089 return $checkOnly ? false : null;
00090 else if($checkOnly)
00091 return $list > 0;
00092 else
00093 return $list[0];
00094 }
00095
00104 public static function exists($constraints = array()) {
00105 return self::retrieve($constraints, true);
00106 }
00107
00120 public static function retrieveMulti($constraints = array(), $checkOnly = false, $depth = 1) {
00121 $list = self::getListMulti($constraints, array(1), array(), $checkOnly, $depth);
00122 if(!$list || count($list) == 0)
00123 return $checkOnly ? false : null;
00124 else if($checkOnly)
00125 return $list > 0;
00126 else
00127 return $list[0];
00128 }
00129
00138 public static function existsMulti($constraints = array()) {
00139 return self::retrieveMulti($constraints, true);
00140 }
00141
00155 public static function getList($constraints = array(), $limit = array(), $order = array(), $count = false) {
00156 return parent::getListBase(self::getDBI(), $constraints, $limit, $order, $count, 'SDRDateValue', true);
00157 }
00158
00174 public static function getListMulti($constraints = array(), $limit = array(), $order = array(), $count = false, $depth = 1) {
00175 return parent::getListBaseMulti(self::getDBI(), $constraints, $limit, $order, $count,
00176 'SDRDateValue', true, $depth);
00177 }
00178
00179
00188 public function getParentValue() {
00189 return SDRValue::retrieve(array('id' => $this->valueId));
00190 }
00191
00201 public function getParentValueMulti($depth = 1) {
00202 return SDRValue::retrieveMulti(array('Base.id' => $this->valueId), false, $depth);
00203 }
00204 }
00205
00206 ?>