Beispiel #1
0
 function __construct($args = array())
 {
     $args = array_merge(array('depth' => 'questionnaire'), $args);
     if (!isset(self::$questionnaireTable)) {
         self::$questionnaireTable = QFrame_Db_Table::getTable('questionnaire');
     }
     if (!isset(self::$instanceTable)) {
         self::$instanceTable = QFrame_Db_Table::getTable('instance');
     }
     if (isset($args['questionnaireID'])) {
         $where = self::$questionnaireTable->getAdapter()->quoteInto('questionnaireID = ?', intVal($args['questionnaireID']));
         $this->questionnaireRow = self::$questionnaireTable->fetchRow($where);
     } elseif (isset($args['questionnaireName']) && isset($args['questionnaireVersion']) && isset($args['revision'])) {
         $adapter = self::$questionnaireTable->getAdapter();
         $where = $adapter->quoteInto('questionnaireName = ?', $args['questionnaireName']) . ' AND ' . $adapter->quoteInto('questionnaireVersion = ?', $args['questionnaireVersion']) . ' AND ' . $adapter->quoteInto('revision = ?', $args['revision']);
         $this->questionnaireRow = self::$questionnaireTable->fetchRow($where);
     } else {
         throw new InvalidArgumentException('Missing arguments to QuestionnaireModel constructor');
     }
     // questionnaire row assertion
     if ($this->questionnaireRow === NULL) {
         throw new Exception('Questionnaire not found');
     }
     if ($args['depth'] !== 'questionnaire') {
         $this->depth = $args['depth'];
         $this->_loadInstances();
     }
 }