00001 <?php
00002
00012 class SDRTextValue 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 'type' => 'string'
00024 ),
00025 'value' => array(
00026 'commit' => SModel2::COMMIT_FOREIGN,
00027 'type' => 'SDRValue'
00028 )
00029 );
00030
00040 public function __construct($constraints = null, $multi = false) {
00041 parent::__construct();
00042
00043 $this->registerAttributes(self::$ATTRIBUTES);
00044 $this->registerTableName('SDRTextValue');
00045 $this->registerPrimaryKey('valueId');
00046
00047 if($constraints !== null)
00048 $this->populate($constraints, $multi);
00049 }
00050
00060 public static function getAttributesStatic() {
00061 return self::$ATTRIBUTES;
00062 }
00063
00069 public static function getTableNameStatic() {
00070 return 'SDRTextValue';
00071 }
00072
00084 public static function retrieve($constraints = array(), $checkOnly = false) {
00085 $list = self::getList($constraints, array(1), array(), $checkOnly);
00086 if(!$list || count($list) == 0)
00087 return $checkOnly ? false : null;
00088 else if($checkOnly)
00089 return $list > 0;
00090 else
00091 return $list[0];
00092 }
00093
00102 public static function exists($constraints = array()) {
00103 return self::retrieve($constraints, true);
00104 }
00105
00118 public static function retrieveMulti($constraints = array(), $checkOnly = false, $depth = 1) {
00119 $list = self::getListMulti($constraints, array(1), array(), $checkOnly, $depth);
00120 if(!$list || count($list) == 0)
00121 return $checkOnly ? false : null;
00122 else if($checkOnly)
00123 return $list > 0;
00124 else
00125 return $list[0];
00126 }
00127
00136 public static function existsMulti($constraints = array()) {
00137 return self::retrieveMulti($constraints, true);
00138 }
00139
00153 public static function getList($constraints = array(), $limit = array(), $order = array(), $count = false) {
00154 return parent::getListBase(self::getDBI(), $constraints, $limit, $order, $count, 'SDRTextValue', true);
00155 }
00156
00172 public static function getListMulti($constraints = array(), $limit = array(), $order = array(), $count = false, $depth = 1) {
00173 return parent::getListBaseMulti(self::getDBI(), $constraints, $limit, $order, $count,
00174 'SDRTextValue', true, $depth);
00175 }
00176
00177
00186 public function getParentValue() {
00187 return SDRValue::retrieve(array('id' => $this->valueId));
00188 }
00189
00199 public function getParentValueMulti($depth = 1) {
00200 return SDRValue::retrieveMulti(array('Base.id' => $this->valueId), false, $depth);
00201 }
00202 }
00203
00204 ?>