/** * Create a new ModelModel * * @param string name The human-readable name of the model * @param integer questionnaireID The numeric identifier of the questionnaire * @return ModelModel */ public static function create($name, $questionnaireID) { if (!isset(self::$modelTable)) { self::$modelTable = QFrame_Db_Table::getTable('model'); } if (strlen($name) < 3) { throw new Exception('Model name must be at least 3 characters'); } $questionnaire = new QuestionnaireModel(array('questionnaireID' => $questionnaireID, 'depth' => 'questionnaire')); $row = self::$modelTable->createRow(); $row->name = $name; $row->questionnaireID = $questionnaire->questionnaireID; $row->save(); $model = new ModelModel(array('modelID' => $row->modelID)); return $model; }