00001 <?php
00002
00012 class CSERDreviewSubject extends CSERDModelBase {
00014 public static $ATTRIBUTES = array(
00015 'subjectId' => array(
00016 'commit' => SModel2::COMMIT_FIRST,
00017 'type' => 'int',
00018 'default' => null,
00019 'foreign' => array('table' => 'subject', 'on' => 'subjectId', 'object' => 'subject')
00020 ),
00021 'reviewId' => array(
00022 'commit' => SModel2::COMMIT_FIRST,
00023 'type' => 'int',
00024 'default' => null,
00025 'foreign' => array('table' => 'review', 'on' => 'reviewId', 'object' => 'review')
00026 ),
00027 'subject' => array(
00028 'commit' => SModel2::COMMIT_FOREIGN,
00029 'type' => 'CSERDsubject'
00030 ),
00031 'review' => array(
00032 'commit' => SModel2::COMMIT_FOREIGN,
00033 'type' => 'CSERDreview'
00034 )
00035 );
00036
00046 public function __construct($constraints = null, $multi = false) {
00047 parent::__construct();
00048
00049 $this->registerAttributes(self::$ATTRIBUTES);
00050 $this->registerTableName('reviewSubject');
00051
00052 if($constraints !== null)
00053 $this->populate($constraints, $multi);
00054 }
00055
00065 public static function getAttributesStatic() {
00066 return self::$ATTRIBUTES;
00067 }
00068
00074 public static function getTableNameStatic() {
00075 return 'reviewSubject';
00076 }
00077
00089 public static function retrieve($constraints = array(), $checkOnly = false) {
00090 $list = self::getList($constraints, array(1), array(), $checkOnly);
00091 if(!$list || count($list) == 0)
00092 return $checkOnly ? false : null;
00093 else if($checkOnly)
00094 return $list > 0;
00095 else
00096 return $list[0];
00097 }
00098
00107 public static function exists($constraints = array()) {
00108 return self::retrieve($constraints, true);
00109 }
00110
00123 public static function retrieveMulti($constraints = array(), $checkOnly = false, $depth = 1) {
00124 $list = self::getListMulti($constraints, array(1), array(), $checkOnly, $depth);
00125 if(!$list || count($list) == 0)
00126 return $checkOnly ? false : null;
00127 else if($checkOnly)
00128 return $list > 0;
00129 else
00130 return $list[0];
00131 }
00132
00141 public static function existsMulti($constraints = array()) {
00142 return self::retrieveMulti($constraints, true);
00143 }
00144
00158 public static function getList($constraints = array(), $limit = array(), $order = array(), $count = false) {
00159 return parent::getListBase(self::getDBI(), $constraints, $limit, $order, $count, 'CSERDreviewSubject', true);
00160 }
00161
00177 public static function getListMulti($constraints = array(), $limit = array(), $order = array(), $count = false, $depth = 1) {
00178 return parent::getListBaseMulti(self::getDBI(), $constraints, $limit, $order, $count,
00179 'CSERDreviewSubject', true, $depth);
00180 }
00181
00182
00191 public function getParentSubject() {
00192 return CSERDsubject::retrieve(array('subjectId' => $this->subjectId));
00193 }
00194
00204 public function getParentSubjectMulti($depth = 1) {
00205 return CSERDsubject::retrieveMulti(array('Base.subjectId' => $this->subjectId), false, $depth);
00206 }
00207
00216 public function getParentReview() {
00217 return CSERDreview::retrieve(array('reviewId' => $this->reviewId));
00218 }
00219
00229 public function getParentReviewMulti($depth = 1) {
00230 return CSERDreview::retrieveMulti(array('Base.reviewId' => $this->reviewId), false, $depth);
00231 }
00232 }
00233
00234 ?>