本文整理汇总了PHP中Subject::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Subject::save方法的具体用法?PHP Subject::save怎么用?PHP Subject::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subject
的用法示例。
在下文中一共展示了Subject::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionAdd
public function actionAdd()
{
global $arr_response;
$model = new Subject();
$model->scenario = 'add';
$_REQUEST['content_type_id'] = ContentType::model()->find('name=:name', array(':name' => $_REQUEST['content_type']))->id;
$_REQUEST['country_id'] = Country::model()->find('code=:code', array(':code' => $_REQUEST['country_code']))->id;
$_REQUEST['priority_id'] = Priority::model()->find('name=:name', array(':name' => $_REQUEST['priority']))->id;
if ($_REQUEST['time']) {
if (date("l", $_REQUEST['time'])) {
//if its a valid timestamp
$_REQUEST['user_position_ymd'] = date("Y", $_REQUEST['time']) . "/" . date("m", $_REQUEST['time']) . "/" . date("d", $_REQUEST['time']);
$_REQUEST['user_position_hour'] = date("H", $_REQUEST['time']);
$_REQUEST['user_position_minute'] = date("i", $_REQUEST['time']);
}
} else {
$_REQUEST['user_position_anydatetime'] = 1;
}
$model->attributes = $_REQUEST;
//NOTICE that we are creating a new record, so model its not loaded, ($model->content_type its juest the received $_REQUEST parameter)
//print_r($model);
//$model->content_type_id = $content_type->id;
if ($model->save()) {
$arr_response['response_message'] = Yii::t('subject', 'Subject successfully saved.');
} else {
$arr_response['response_code'] = 409;
$arr_response['response_message'] = Yii::t('subject', 'Subject could not be saved.');
$arr_response['response_details'] = $model->getErrors();
}
}
示例2: store
public function store()
{
$subject = new Subject();
$subject->name = Input::get('name');
$subject->save();
Session::flash('message', 'Sukses menambahkan bidang studi baru!');
}
示例3: create
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
$rules = ['name' => 'required', 'code' => 'required', 'type' => 'required', 'subgroup' => 'required', 'stdgroup' => 'required', 'class' => 'required', 'totalfull' => 'required', 'wfull' => 'required', 'mfull' => 'required', 'sfull' => 'required', 'pfull' => 'required'];
$validator = \Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::to('/subject/create')->withErrors($validator);
} else {
$exsubject = Subject::select('*')->where('class', Input::get('class'))->where('code', Input::get('code'))->get();
if (count($exsubject) > 0) {
$errorMessages = new Illuminate\Support\MessageBag();
$errorMessages->add('deplicate', 'subject all ready exists for this class!!');
return Redirect::to('/subject/create')->withErrors($errorMessages);
} else {
$subject = new Subject();
$subject->name = Input::get('name');
$subject->code = Input::get('code');
$subject->class = Input::get('class');
$subject->type = Input::get('type');
$subject->subgroup = Input::get('subgroup');
$subject->stdgroup = Input::get('stdgroup');
$subject->totalfull = Input::get('totalfull');
$subject->totalpass = Input::get('totalpass');
$subject->wfull = Input::get('wfull');
$subject->wpass = Input::get('wpass');
$subject->mfull = Input::get('mfull');
$subject->mpass = Input::get('mpass');
$subject->sfull = Input::get('sfull');
$subject->spass = Input::get('spass');
$subject->pfull = Input::get('pfull');
$subject->ppass = Input::get('ppass');
$subject->save();
return Redirect::to('/subject/create')->with("success", "Subject Created Succesfully.");
}
}
}
示例4: actionCreate
/**
* 录入
*
*/
public function actionCreate()
{
parent::_acl('subject_create');
$model = new Subject();
$imageList = $this->_gets->getPost('imageList');
$layoutList = $this->_gets->getPost('layoutList');
$imageListSerialize = XUtils::imageListSerialize($imageList);
$layoutListSerialize = XUtils::imageListSerialize($layoutList);
if (isset($_POST['Subject'])) {
$file = XUpload::upload($_FILES['attach']);
$model->attributes = $_POST['Subject'];
$model->date = strtotime($_POST['Subject']['date']);
if (is_array($file)) {
$model->room_type_image = $file['pathname'];
}
$model->image_list = $imageListSerialize['dataSerialize'];
$model->layout_list = $layoutListSerialize['dataSerialize'];
if ($model->save()) {
AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入项目,ID:' . $model->id));
$this->redirect(array('index'));
}
}
$this->city_list = parent::_groupList('city');
$this->render('create', array('model' => $model, 'imageList' => $imageListSerialize['data'], 'layoutList' => $layoutListSerialize['data']));
}
示例5: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Eloquent::unguard();
DB::table('propel_fellow_wingman')->delete();
DB::table('propel_student_wingman')->delete();
Subject::truncate();
DB::table('propel_city_subject')->delete();
CalendarEvent::truncate();
CancelledCalendarEvent::truncate();
WingmanModule::truncate();
WingmanTime::truncate();
VolunteerTime::truncate();
WingmanJournal::truncate();
$fellow = Fellow::find(1);
$wingman1 = Wingman::find(2);
$wingman2 = Wingman::find(3);
$fellow->wingman()->attach($wingman1);
$fellow->wingman()->attach($wingman2);
$student1 = Student::find(3);
$student2 = Student::find(4);
$wingman1->student()->attach($student1);
$wingman1->student()->attach($student2);
$cEvent1 = new CalendarEvent();
$cEvent1->type = 'volunteer_time';
$cEvent1->student()->associate($student1);
$cEvent1->status = 'created';
$cEvent1->save();
$vTime1 = new VolunteerTime();
$vTime1->calendarEvent()->associate($cEvent1);
$volunteer1 = Volunteer::find(4);
$vTime1->volunteer()->associate($volunteer1);
$subject1 = new Subject();
$subject1->name = "English";
$subject1->save();
$vTime1->subject()->associate($subject1);
$vTime1->save();
$cEvent2 = new CalendarEvent();
$cEvent2->type = 'wingman_time';
$cEvent2->student()->associate($student1);
$cEvent2->status = 'created';
$cEvent2->save();
$wTime1 = new WingmanTime();
$wTime1->calendarEvent()->associate($cEvent2);
$wTime1->wingman()->associate($wingman1);
$wModule1 = new WingmanModule();
$wModule1->name = "Programming";
$wModule1->save();
$wTime1->wingmanModule()->associate($wModule1);
$wTime1->save();
$city1 = City::find(1);
$subject1->city()->attach($city1);
$wJournal1 = new WingmanJournal();
$wJournal1->type = 'formal';
$wJournal1->title = "Day at Navy Camp";
$wJournal1->mom = "It was awesome";
$wJournal1->student()->associate($student1);
$wJournal1->wingman()->associate($wingman1);
$wJournal1->save();
}
示例6: create
private function create()
{
$subject = new Subject();
$subject->subjectname = Input::get('name');
$subject->subjectcode = Input::get('code');
$subject->grade = Input::get('grade');
$subject->save();
}
示例7: actionCreate
/**
* Создает новую модель Предмета.
* Если создание прошло успешно - перенаправляет на просмотр.
*
* @return void
*/
public function actionCreate()
{
$model = new Subject();
if (Yii::app()->getRequest()->getPost('Subject') !== null) {
$model->setAttributes(Yii::app()->getRequest()->getPost('Subject'));
if ($model->save()) {
Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('SubjectModule.subject', 'Запись добавлена!'));
$this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['update', 'id' => $model->id]));
}
}
$this->render('create', ['model' => $model]);
}
示例8: save
public function save()
{
$subjectId = $this->getValue('subjectId');
if (!empty($subjectId)) {
$subject = $this->getSubjectService()->getSubjectById($subjectId);
} else {
$subject = new Subject();
}
$subject->setCode($this->getValue('code'));
$subject->setName($this->getValue('name'));
$subject->save();
}
示例9: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Subject();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Subject'])) {
$model->attributes = $_POST['Subject'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例10: actionCreate
/**
* Создает новую модель Предмета.
* Если создание прошло успешно - перенаправляет на просмотр.
*
* @return void
*/
public function actionCreate()
{
$roles = ['1', '5', '4'];
$role = \Yii::app()->user->role;
if (array_intersect($role, $roles)) {
$model = new Subject();
if (Yii::app()->getRequest()->getPost('Subject') !== null) {
$model->setAttributes(Yii::app()->getRequest()->getPost('Subject'));
if ($model->save()) {
Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('SubjectModule.subject', 'Запись добавлена!'));
$this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['update', 'id' => $model->id]));
}
}
$this->render('create', ['model' => $model]);
} else {
throw new CHttpException(403, 'Ошибка прав доступа.');
}
}
示例11: addSubject
/**
* Store a subject in the Subject collection
*
* @return View
*/
public function addSubject()
{
$subject = new Subject();
$subject->name = strtoupper(trim(Input::get('subject_name')));
$subject->university_id = Auth::id();
$subject->school = strtoupper(trim(Input::get('school')));
$sections = explode(',', Input::get('section'));
foreach ($sections as $section) {
$sect = new Section();
$sect->code = strtoupper(trim($section));
$sect->is_free = true;
$subject->sections()->associate($sect);
}
try {
$subject->save();
} catch (MongoDuplicateKeyException $e) {
return Redirect::back()->withErrors(array('error' => Lang::get('add_subject.subject_duplicated')));
}
return Redirect::to(Lang::get('routes.add_subject'))->with('message', Lang::get('add_subject.success'));
}
示例12: executeUpdate
public function executeUpdate()
{
$i18n = new sfI18N();
$i18n->initialize($this->getContext());
$i18n->setCulture($this->getUser()->getCulture());
$action_i18n = $i18n->globalMessageFormat->format('save as new');
$action_type = $this->getRequestParameter('action_type');
if ($action_type == $action_i18n || !$this->getRequestParameter('id')) {
$subject = new Subject();
$subject->setCode($this->getRequestParameter('code'));
$subject->setName($this->getRequestParameter('name'));
$subject->setCredit($this->getRequestParameter('credit'));
$subject->setSubjectGroupId($this->getRequestParameter('subject_group_id'));
$subject->setDepartmentId($this->getRequestParameter('department_id'));
$subject->save();
#$subject_curr = new SubjectCurr();
#$subject_curr->setSubject($subject);
#$subject_curr->setCurriculumId($this->getRequestParameter('curriculum_id'));
#$subject_curr->save();
#$c = new Criteria();
#$c->add(AcademicCalendarPeer::CURRICULUM_ID, $this->getRequestParameter('curriculum_id'));
#$currs = AcademicCalendarPeer::doSelect($c);
#foreach ($currs as $curr) {
# $subject_accal = new SubjectAccal();
# $subject_accal->setSubject($subject);
# $subject_accal->setAcademicCalendarId($curr->getId());
# $subject_accal->setEmployeeId($this->getRequestParameter('employee_id'));
# $subject_accal->save();
# $subject_accal_lector = new SubjectAccalLector();
# $subject_accal_lector->setSubjectAccal($subject_accal);
# $subject_accal_lector->setEmployeeId($this->getRequestParameter('employee_id'));
# $subject_accal_lector->save();
#}
$subject_accal = new SubjectAccal();
$subject_accal->setSubject($subject);
$subject_accal->setAcademicCalendarId($this->getRequestParameter('academic_calendar_id'));
$subject_accal->setEmployeeId($this->getRequestParameter('employee_id'));
$subject_accal->save();
#$subject_accal_lector = new SubjectAccalLector();
#$subject_accal_lector->setSubjectAccal($subject_accal);
#$subject_accal_lector->setEmployeeId($this->getRequestParameter('employee_id'));
#$subject_accal_lector->save();
} else {
$subject = SubjectPeer::retrieveByPk($this->getRequestParameter('id'));
$this->forward404Unless($subject);
$subject->setId($this->getRequestParameter('id'));
$subject->setCode($this->getRequestParameter('code'));
$subject->setName($this->getRequestParameter('name'));
$subject->setCredit($this->getRequestParameter('credit'));
$subject->setSubjectGroupId($this->getRequestParameter('subject_group_id'));
$subject->setDepartmentId($this->getRequestParameter('department_id'));
$subject->save();
$c = new Criteria();
$c->add(SubjectAccalPeer::ID, $this->getRequestParameter('subject_accal_id'));
$subject_accal = SubjectAccalPeer::doSelectOne($c);
#$subject_accal = SubjectAccalPeer::retrieveByPk($this->getRequestParameter('subject_accal_id'));
#$this->forward404Unless($subject_accal);
$subject_accal->setId('subject_accal_id');
$subject_accal->setSubject($subject);
$subject_accal->setAcademicCalendarId($this->getRequestParameter('academic_calendar_id'));
$subject_accal->setEmployeeId($this->getRequestParameter('employee_id'));
$subject_accal->save();
}
return $this->redirect('subject/list');
}
示例13: Subject
</select>
</div>
</fieldset>
<fieldset class="buttons">
<button type="reset">reset</button>
<button type="submit"
name="stage"
value="2">submit</button>
</fieldset>
</form>
</div>';
break;
case "2":
$subject = new Subject("00000", $_POST["code"], $_POST["name"], $_POST["description"], $_POST["startYear"], $_POST["stopYear"]);
if ($subject->validate()) {
if ($subject->save()) {
$pageBody .= '
<table>
<tbody>
<tr>
<th>code</th>
<td>' . $subject->getCode() . '</td>
</tr>
<tr>
<th>name</th>
<td>' . $subject->getName() . '</td>
</tr>
<tr>
<th>description</th>
<td>' . $subject->getDescription() . '</td>
</tr>
示例14: actionAjaxCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionAjaxCreate()
{
$model = new Subject();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Subject'])) {
$model->attributes = $_POST['Subject'];
if ($model->save()) {
$this->redirect(array('index', 'id' => $model->ID));
}
}
$this->renderPartial('_form', array('model' => $model), false, true);
}
示例15: navigation
<?php
require_once '../../includes/initialize.php';
?>
<?php
selected_page();
if (isset($_POST['submit'])) {
$new_subject = new Subject();
$new_subject->menu_name = trim($_POST['menu_name']);
$new_subject->visible = (int) trim($_POST['visible']);
$new_subject->position = (int) trim($_POST['position']);
if ($new_subject->save()) {
$message = "New Subject Added";
} else {
$message = "Failed to Add New Subject";
}
}
include_layout_template("admin_header");
?>
<nav>
<br>
<a href="index.php">« Back</a>
<br>
<?php
echo navigation($current_subject, $current_page);
?>
</nav>
<div class="page">