00001 <?php
00002
00012 class CSERDresponse extends CSERDModelBase {
00014 public static $ATTRIBUTES = array(
00015 'responseId' => array(
00016 'nullable' => false,
00017 'commit' => SModel2::COMMIT_NEVER,
00018 'type' => 'int'
00019 ),
00020 'questionId' => array(
00021 'nullable' => false,
00022 'commit' => SModel2::COMMIT_FIRST,
00023 'type' => 'int',
00024 'foreign' => array('table' => 'question', 'on' => 'questionId', 'object' => 'question')
00025 ),
00026 'reviewId' => array(
00027 'nullable' => false,
00028 'commit' => SModel2::COMMIT_FIRST,
00029 'type' => 'int',
00030 'foreign' => array('table' => 'review', 'on' => 'reviewId', 'object' => 'review')
00031 ),
00032 'response' => array(
00033 'type' => 'string'
00034 ),
00035 'review' => array(
00036 'commit' => SModel2::COMMIT_FOREIGN,
00037 'type' => 'CSERDreview'
00038 ),
00039 'question' => array(
00040 'commit' => SModel2::COMMIT_FOREIGN,
00041 'type' => 'CSERDquestion'
00042 )
00043 );
00044
00054 public function __construct($constraints = null, $multi = false) {
00055 parent::__construct();
00056
00057 $this->registerAttributes(self::$ATTRIBUTES);
00058 $this->registerTableName('response');
00059 $this->registerPrimaryKey('responseId', true);
00060
00061 if($constraints !== null)
00062 $this->populate($constraints, $multi);
00063 }
00064
00074 public static function getAttributesStatic() {
00075 return self::$ATTRIBUTES;
00076 }
00077
00083 public static function getTableNameStatic() {
00084 return 'response';
00085 }
00086
00098 public static function retrieve($constraints = array(), $checkOnly = false) {
00099 $list = self::getList($constraints, array(1), array(), $checkOnly);
00100 if(!$list || count($list) == 0)
00101 return $checkOnly ? false : null;
00102 else if($checkOnly)
00103 return $list > 0;
00104 else
00105 return $list[0];
00106 }
00107
00116 public static function exists($constraints = array()) {
00117 return self::retrieve($constraints, true);
00118 }
00119
00132 public static function retrieveMulti($constraints = array(), $checkOnly = false, $depth = 1) {
00133 $list = self::getListMulti($constraints, array(1), array(), $checkOnly, $depth);
00134 if(!$list || count($list) == 0)
00135 return $checkOnly ? false : null;
00136 else if($checkOnly)
00137 return $list > 0;
00138 else
00139 return $list[0];
00140 }
00141
00150 public static function existsMulti($constraints = array()) {
00151 return self::retrieveMulti($constraints, true);
00152 }
00153
00167 public static function getList($constraints = array(), $limit = array(), $order = array(), $count = false) {
00168 return parent::getListBase(self::getDBI(), $constraints, $limit, $order, $count, 'CSERDresponse', true);
00169 }
00170
00186 public static function getListMulti($constraints = array(), $limit = array(), $order = array(), $count = false, $depth = 1) {
00187 return parent::getListBaseMulti(self::getDBI(), $constraints, $limit, $order, $count,
00188 'CSERDresponse', true, $depth);
00189 }
00190
00191
00200 public function getParentQuestion() {
00201 return CSERDquestion::retrieve(array('questionId' => $this->questionId));
00202 }
00203
00213 public function getParentQuestionMulti($depth = 1) {
00214 return CSERDquestion::retrieveMulti(array('Base.questionId' => $this->questionId), false, $depth);
00215 }
00216
00225 public function getParentReview() {
00226 return CSERDreview::retrieve(array('reviewId' => $this->reviewId));
00227 }
00228
00238 public function getParentReviewMulti($depth = 1) {
00239 return CSERDreview::retrieveMulti(array('Base.reviewId' => $this->reviewId), false, $depth);
00240 }
00241 }
00242
00243 ?>