本文整理汇总了PHP中Part::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Part::save方法的具体用法?PHP Part::save怎么用?PHP Part::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Part
的用法示例。
在下文中一共展示了Part::save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Part();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Part'])) {
$model->attributes = $_POST['Part'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例2: savePart
private function savePart()
{
$form = 'frost.views.cms.part.text.TextAdd';
$part = Part::addMediaToPart($form,'Text');
// Add the 'preview' to the part
$part = new Part();
$part->clauseSafe('part_id',Application::param('part_id'));
$part->parse();
$part->save();
//Part::setParttagsAndSave($part,Application::param('current_tags'));
Application::setParam('module_id',Application::param('module_id'));
Application::redirect('ModuleDetail');
}
示例3: addquestions
public function addquestions($filename)
{
PHPExcel_Settings::setCacheStorageMethod(PHPExcel_CachedObjectStorageFactory::cache_in_memory_gzip);
$files = scandir("./upload");
array_shift($files);
array_shift($files);
$errors = array();
$factors = array();
$j = 0;
$this->db->begin();
foreach ($files as $file) {
if (strstr($file, $filename)) {
$objexcel = PHPExcel_IOFactory::load("./upload/" . $file);
$factorsheet = $objexcel->getSheet(0);
$questionsheet = $objexcel->getSheet(1);
$part = new Part();
$part->type = 0;
$part->name = (string) $factorsheet->getCell("B2")->getValue();
$part->description = (string) $factorsheet->getCell("B3")->getValue();
try {
if (!$part->save()) {
$errors[$j]['error'] = "part";
foreach ($part->getMessages() as $key => $message) {
$errors[$j][$key] = $message;
}
$j++;
$this->db->rollback();
$objexcel->disconnectWorksheets();
unlink("./upload/" . $file);
return $errors;
} else {
$higestrow = $factorsheet->getHighestRow();
$i = 5;
while ($i <= $higestrow) {
$factor = new Factor();
$factor->ratio = $factorsheet->getCell("B" . $i)->getValue();
$k = $factorsheet->getCell("A" . $i)->getValue();
if (is_null($k) || $k == "") {
break;
}
if ($factor->save()) {
$factors["{$k}"] = $factor->f_id;
$fprel = new Fprel();
$fprel->factor_id = $factor->f_id;
$fprel->part_id = $part->p_id;
if (!$fprel->save()) {
$errors[$j]['error'] = "fprel";
foreach ($fprel->getMessages() as $key => $message) {
$errors[$j][$key] = $message;
}
$j++;
$this->db->rollback();
$objexcel->disconnectWorksheets();
unlink("./upload/" . $file);
return $errors;
}
} else {
$errors[$j]['error'] = "factor";
foreach ($factor->getMessages() as $key => $message) {
$errors[$j][$key] = $message;
}
$j++;
$this->db->rollback();
$objexcel->disconnectWorksheets();
unlink("./upload/" . $file);
return $errors;
}
$i++;
}
$higestrow = $questionsheet->getHighestRow();
//不可靠
$i = 3;
while ($i <= $higestrow) {
$question = new Question();
$topic = (string) $questionsheet->getCell("A" . $i)->getValue();
if (is_null($topic) || $topic == "") {
break;
}
$question->topic = $topic;
$question->factor_id = $factors[$questionsheet->getCell("C" . $i)->getValue()];
$question->options = "";
$question->grade = "";
$col = "D";
$colnum = $questionsheet->getCell("B" . $i)->getValue();
for ($k = 1; $k <= $colnum; $k++, $col++) {
$str = $questionsheet->getCell($col . $i)->getValue();
$mem = explode("|", $str);
$question->options .= "|" . $mem[0];
$question->grade .= "|" . $mem[1];
}
$question->options = substr($question->options, 1);
$question->grade = substr($question->grade, 1);
if (!$question->save()) {
$errors[$j]['error'] = "question";
$errors[$j]['maxrow'] = $higestrow;
foreach ($question->getMessages() as $key => $message) {
$errors[$j][$key] = $message;
}
$j++;
$this->db->rollback();
//.........这里部分代码省略.........