当前位置: 首页>>代码示例>>PHP>>正文


PHP Project::save方法代码示例

本文整理汇总了PHP中Project::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::save方法的具体用法?PHP Project::save怎么用?PHP Project::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Project的用法示例。


在下文中一共展示了Project::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCRUD

 public function testCRUD()
 {
     //CREATE Test
     $newProject = new Project();
     $projectName = 'This is a Test';
     $newProject->setAttributes(array('name' => $projectName, 'description' => 'This project is for test purpose only', 'start_date' => '2010-11-15 15:00:00', 'end_date' => '2010-12-06 00:00:00', 'update_user_id' => 1, 'category' => 2, 'status' => 1, 'owner' => 1));
     $this->assertTrue($newProject->save(false));
     //READ Test
     $readProject = Project::model()->findByPk($newProject->id);
     $this->assertTrue($readProject instanceof Project);
     $this->assertEquals($projectName, $readProject->name);
     //UPDATE Test
     $updateProjectName = 'Updated Name2';
     $newProject->name = $updateProjectName;
     $this->AssertTrue($newProject->save(false));
     $updatedProject = Project::model()->findByPk($newProject->id);
     $this->assertTrue($updatedProject instanceof Project);
     $this->assertNotEquals($projectName, $updatedProject->name);
     //DELETE Test
     $deletedProjectId = $newProject->id;
     $newProject->delete();
     $deletedProject = Project::model()->findByPk($newProject->id);
     $this->assertEquals(Null, $deletedProject);
     //GetUserVote Test
     $project = Project::model()->findByPk(18);
     $this->assertTrue($project->getUserVote(7) == true);
     //Vote Test
     $this->assertTrue($project->vote(1, 1) == 1);
 }
开发者ID:rknox,项目名称:PPM-App,代码行数:29,代码来源:CRUDTest.php

示例2: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Project();
     $model->attributes = $_POST;
     $result = $model->save();
     $this->sendAjaxResponse($model);
 }
开发者ID:pdooley,项目名称:genesis,代码行数:11,代码来源:ProjectController.php

示例3: action_create

 public function action_create()
 {
     $project_input = Input::get('project');
     if ($project_input["project_type_id"] == "Other") {
         if (!Input::get('new_project_type_name')) {
             Session::flash('errors', array(__("r.flashes.new_project_no_project_type")));
             return Redirect::to_route('new_projects')->with_input();
         } elseif ($existing_project_type = ProjectType::where_name(Input::get('new_project_type_name'))->first()) {
             $project_input["project_type_id"] = $existing_project_type->id;
         } else {
             $project_type = new ProjectType(array('name' => Input::get('new_project_type_name')));
             $project_type->save();
             $project_input["project_type_id"] = $project_type->id;
         }
     }
     $project = new Project($project_input);
     $dt = new \DateTime($project_input["proposals_due_at"], new DateTimeZone('America/New_York'));
     // if user doesn't specify a date, set it to 1 month from now
     if (!$project_input["proposals_due_at"]) {
         $dt->modify('+1 month');
     }
     $dt->setTimeZone(new DateTimeZone('UTC'));
     $project->proposals_due_at = $dt;
     if ($project->validator()->passes()) {
         $project->save();
         $project->officers()->attach(Auth::officer()->id, array('owner' => true));
         return Redirect::to_route('project_template', array($project->id));
     } else {
         Session::flash('errors', $project->validator()->errors->all());
         return Redirect::to_route('new_projects')->with_input();
     }
 }
开发者ID:ajb,项目名称:rfpez,代码行数:32,代码来源:projects.php

示例4: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $userToken = Input::get('token');
     $validation = Validator::make(['projectname' => Input::get('projectname'), 'description' => Input::get('description'), 'start_date' => Input::get('start_date'), 'end_date' => Input::get('end_date')], ['projectname' => 'required|min:4|max:40', 'description' => 'min:10|max:60', 'start_date' => 'required|date_format:"m/d/Y"', 'end_date' => 'required|date_format:"m/d/Y"']);
     if ($validation->fails()) {
         return Redirect::route('dashboard', array($userToken))->withErrors($validation);
     } else {
         $projectName = Input::get('projectname');
         $projectDesc = Input::get('description');
         $projectStart = Input::get('start_date');
         $start_day = date("Y-m-d", strtotime($projectStart));
         $projectEnd = Input::get('end_date');
         $end_day = date("Y-m-d", strtotime($projectEnd));
         $team_id = Input::get('team_id');
         try {
             $project = new Project();
             $project->project_title = $projectName;
             $project->project_desc = $projectDesc;
             $project->team_id = $team_id;
             $project->strat_date = $start_day;
             $project->end_date = $end_day;
             $project->save();
             return Redirect::route('dashboard', array($userToken));
         } catch (Exception $e) {
             echo $e;
             return 'Something is wrong!';
         }
     }
 }
开发者ID:Nabil5352,项目名称:Team-Management-Application,代码行数:34,代码来源:ProjectController.php

示例5: edit

 /**
  * Update project
  *
  * @param void
  * @return null
  */
 function edit()
 {
     $this->wireframe->print_button = false;
     if ($this->request->isApiCall() && !$this->request->isSubmitted()) {
         $this->httpError(HTTP_ERR_BAD_REQUEST, null, true, true);
     }
     // if
     if ($this->active_project->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_project->canEdit($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     $project_data = $this->request->post('project');
     if (!is_array($project_data)) {
         $project_data = array('name' => $this->active_project->getName(), 'overview' => $this->active_project->getOverview(), 'default_visibility' => $this->active_project->getDefaultVisibility(), 'leader_id' => $this->active_project->getLeaderId(), 'group_id' => $this->active_project->getGroupId(), 'company_id' => $this->active_project->getCompanyId(), 'default_visibility' => $this->active_project->getDefaultVisibility(), 'starts_on' => $this->active_project->getStartsOn());
     }
     // if
     $this->smarty->assign('project_data', $project_data);
     if ($this->request->isSubmitted()) {
         db_begin_work();
         $old_name = $this->active_project->getName();
         $this->active_project->setAttributes($project_data);
         if ($this->active_project->isModified('leader_id') && $this->active_project->getLeaderId()) {
             $leader = Users::findById($this->active_project->getLeaderId());
             if (instance_of($leader, 'User')) {
                 $this->active_project->setLeader($leader);
             }
             // if
         }
         // if
         if ($this->active_project->isModified('company_id')) {
             cache_remove('project_icons');
         }
         // if
         $save = $this->active_project->save();
         if ($save && !is_error($save)) {
             db_commit();
             if ($this->request->isApiCall()) {
                 $this->serveData($this->active_project, 'project');
             } else {
                 flash_success('Project :name has been updated', array('name' => $old_name));
                 $this->redirectToUrl($this->active_project->getOverviewUrl());
             }
             // if
         } else {
             db_rollback();
             if ($this->request->isApiCall()) {
                 $this->serveData($save);
             } else {
                 $this->smarty->assign('errors', $save);
             }
             // if
         }
         // if
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:66,代码来源:ProjectController.class.php

示例6: submit

 function submit()
 {
     $data['title'] = 'Submit a Project';
     $project = new Project();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         // Get the scalars.
         $project->from_array($_POST);
         // Convert properly to boolean
         if ($project->show_contact == 'yes') {
             $project->show_contact = TRUE;
         } else {
             $project->show_contact = FALSE;
         }
         // Handle the relations (tags)
         if ($project->save($this->_current_user())) {
             // validations run
             $this->_save_tags($project);
             $this->_submit_on_success();
         } else {
             // invalid
             $data['error'] = $project->error->string;
         }
     }
     // Otherwise, render a form.
     $tags = new Tag();
     foreach (array('field', 'type', 'location') as $category) {
         $tags->where('category', $category)->get();
         $data[$category . '_tags'] = array();
         foreach ($tags as $tag) {
             array_push($data[$category . '_tags'], $tag->name);
         }
     }
     $data['form'] = $project->render_form(array('title', 'start_date', 'end_date', 'field', 'type', 'location', 'text', 'show_contact'));
     $this->load->view('form_project', $data);
 }
开发者ID:kuitang,项目名称:sdi,代码行数:35,代码来源:home.php

示例7: createAssocAction

 public function createAssocAction()
 {
     $user = User::findFirst();
     $project = new Project();
     $project->user = $user;
     $project->title = "Moon walker";
     $result = $project->save();
 }
开发者ID:BBK-PiJ-2014-83,项目名称:learning-phalcon,代码行数:8,代码来源:UserController.php

示例8: createProject

 public static function createProject($id = '')
 {
     $project = new Project();
     $project->name = "testProject";
     $project->team_id = 1;
     $project->team_set_id = 1;
     $project->save();
     self::pushObject($project);
     return $project;
 }
开发者ID:jgera,项目名称:sugarcrm_dev,代码行数:10,代码来源:SugarTestProjectUtilities.php

示例9: store

 /**
  * Store a newly created resource in storage.
  * POST /projects
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $project = new Project($input);
     if ($project->save()) {
         return Redirect::route('projects.index')->with('message', 'Project created.');
     } else {
         return Redirect::route('projects.create')->withInput()->withErrors($project->errors());
     }
 }
开发者ID:marciocamello,项目名称:laravel-ecommerce,代码行数:16,代码来源:ProjectsController.php

示例10: createProjectByNameForOwner

 public static function createProjectByNameForOwner($name, $owner)
 {
     $project = new Project();
     $project->name = $name;
     $project->owner = $owner;
     $project->description = 'Description';
     $saved = $project->save();
     assert('$saved');
     return $project;
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:10,代码来源:ProjectTestHelper.php

示例11: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'show' page.
  */
 public function actionCreate()
 {
     $model = new Project($this->action->id);
     if (isset($_POST['Project'])) {
         // collect user input data
         $model->attributes = $_POST['Project'];
         // validate with the current action as scenario and save without validation
         if (($validated = $model->validate()) !== false && ($saved = $model->save(false)) !== false) {
             if (isset($_POST['Company2Project'])) {
                 // assigned companies
                 $model->allCompany2Project = array(0 => new Company2Project('create'));
                 $model->allCompany2Project[0]->projectId = $model->id;
                 foreach ($model->allCompany2Project as $company2Project) {
                     $company2Project->attributes = $_POST['Company2Project'];
                     $company2Project->save();
                 }
             }
             if (isset($_POST['User2Project'])) {
                 // assigned managers
                 $model->allManager2Project = array(0 => new User2Project('create'));
                 $model->allManager2Project[0]->projectId = $model->id;
                 foreach ($model->allManager2Project as $user2Project) {
                     $user2Project->attributes = $_POST['User2Project'];
                     $user2Project->save();
                 }
             }
             // set success message
             MUserFlash::setTopSuccess(Yii::t('hint', 'The new "{title}" project record has been successfully created.', array('{title}' => MHtml::wrapInTag($model->title, 'strong'))));
             // go to the 'show' page
             $this->redirect(array('show', 'id' => $model->id));
         }
     } else {
         // pre-assigned attributes (default values for a new record)
         $model->priority = Project::PRIORITY_MEDIUM;
         if (isset($_GET['companyId'])) {
             // company is known
             $model->allCompany2Project = array(0 => new Company2Project('create'));
             $model->allCompany2Project[0]->companyId = $_GET['companyId'];
             $model->allCompany2Project[0]->projectId = $model->id;
         }
     }
     if (!isset($model->allCompany2Project[0])) {
         // new associated company
         $model->allCompany2Project = array(0 => new Company2Project('create'));
         $model->allCompany2Project[0]->projectId = $model->id;
     }
     if (!isset($model->allManager2Project[0])) {
         // new associated manager
         $model->allManager2Project = array(0 => new User2Project('create'));
         $model->allManager2Project[0]->projectId = $model->id;
         $model->allManager2Project[0]->role = User2Project::MANAGER;
     }
     $this->render($this->action->id, array('model' => $model));
 }
开发者ID:megabr,项目名称:web3cms,代码行数:58,代码来源:ProjectController.php

示例12: editProject

 public function editProject()
 {
     $id = Input::get('id');
     $project = null;
     if ($id) {
         $this->check_own($id);
         $project = Project::find($id);
     }
     $src_addr = trim(Input::get('src_addr'));
     $error = '';
     if (Request::isMethod('post')) {
         if (!trim(Input::get('title'))) {
             $error = '请填写标题';
         }
         if (!trim(Input::get('manager'))) {
             $error = '请填写项目管理员';
         }
         if (!trim(Input::get('src_addr'))) {
             $error = '请填写源码地址';
         }
         if (!$error) {
             $project_created = false;
             if ($project) {
                 if ($project->src_addr != $src_addr) {
                     //生成task 清理当前source目录
                     $clean_task = Task::create('delete', Auth::id(), array('project_id' => $project->id));
                     //生成task 重新checkout,注意前置任务
                     Task::create('checkout', Auth::id(), array('project_id' => $project->id), $clean_task);
                 }
             } else {
                 $project = new Project();
                 $project_created = true;
             }
             $project->title = trim(Input::get('title'));
             $project->manager = trim(Input::get('manager'));
             $project->vcs_type = trim(Input::get('vcs_type'));
             $project->src_addr = $src_addr;
             $project->ignore_files = trim(Input::get('ignore_files'));
             $project->comments = trim(Input::get('comments'));
             $project->username = trim(Input::get('username'));
             $project->password = trim(Input::get('password'));
             if (!isset(Project::$vcs_types[$project->vcs_type])) {
                 $project->vcs_type = last(array_keys(Project::$vcs_types));
             }
             $project->save();
             if ($project_created) {
                 //生成task checkout
                 Task::create('checkout', Auth::id(), array('project_id' => $project->id));
             }
             return Redirect::action('ProjectsController@allProjects');
         }
     }
     return View::make('projects/edit', array('project' => $project, 'error' => $error));
 }
开发者ID:xiaomantou88,项目名称:svn_publisher,代码行数:54,代码来源:ProjectsController.php

示例13: testNoSave

 public function testNoSave()
 {
     $p = new Project();
     $p->id = 'ABC';
     $p->name = 'abc';
     try {
         $p->save();
     } catch (EQMException $e) {
         $this->assertEquals($e->getMessage(), 'save() is not possible for entities without auto increment primary key');
     }
 }
开发者ID:scandio,项目名称:troba,代码行数:11,代码来源:ModelPersistersTest.php

示例14: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Project();
     if (isset($_POST['Project'])) {
         $model->attributes = $_POST['Project'];
         if ($model->save()) {
             Yii::app()->user->setFlash('success', 'Project ' . $model->name . ' has been created successfully.');
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:xyzz,项目名称:CrashFix,代码行数:16,代码来源:ProjectController.php

示例15: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Project();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Project'])) {
         $model->attributes = $_POST['Project'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:jessesiu,项目名称:GigaDBV3,代码行数:17,代码来源:AdminProjectController.php


注:本文中的Project::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。