getCommandBuilder()->createSqlCommand($sql)->queryRow(); } /** * 初始化教师讲案记录 * @param $examId * @param $productType * @param $subjectId */ public function initialize($examId, $productType, $subjectId){ $model = self::model()->find("exam_id=:id and product_type=:type and subject_id=:subject", array(":id" => $examId,":type"=>$productType,":subject"=>$subjectId)); if(!$model){ $model = new self(); $model->exam_id = $examId; $model->subject_id = $subjectId; $model->product_type = $productType; $model->create_time = time(); $model->update_time = time(); $model->save(false); } } /** * 教师版是否生成 * @param $examId * @param $productType * @return bool */ public static function isGenerate($examId, $productType){ $rs = self::model()->find("exam_id=:id and product_type=:type and is_create_pdf=1", array(":id" => $examId,":type"=>$productType)); return $rs ? true : false; } }