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


PHP Test::save方法代码示例

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


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

示例1: addBatch

 function addBatch()
 {
     $users = str_getcsv($_POST['users']);
     $saved = TRUE;
     $testid = $this->session->userdata('testid');
     $test = new Test();
     $test->get_by_id($testid);
     $this->load->helper("pinyin");
     foreach ($users as $user) {
         $u = new User();
         $u->uStudId = $user[0];
         $u->uName = str_replace(' ', '', $user[1]);
         //$u->uPassword = $user[0];//密码等于用户的学号
         $pinyin = get_pinyin($u->uName);
         $u->uPassword = str_replace('_', '', $pinyin);
         //用拼音作为密码
         $u->uType = 'student';
         if (!$u->save()) {
             $saved = FALSE;
             break;
         }
         $test->save($u);
     }
     return 'saved';
 }
开发者ID:htom78,项目名称:peersay,代码行数:25,代码来源:users.php

示例2: testRowMethods

 function testRowMethods()
 {
     $id = $this->addRow();
     $tr = new Test();
     $loaded = $tr->load($id);
     $this->assert($updatedRow = $loaded, "Test->load() failed: " . var_export($loaded, 1));
     $exp = $tr->export();
     $this->assert($updatedRow = $exp, "Test->export() failed: " . var_export($exp, 1));
     $newname = 'test updated again';
     $tr->name = $newname;
     $save = $tr->save();
     $this->assert($save, "Test->save() failed: " . var_export($tr->getErrorList(), 1));
     $this->assert(Test::count() == 1, "Test::count() failed");
     $tr->name = null;
     $this->assert(!$tr->save(), "Test->save() should have failed (required name rule should fail)!");
     $tr->name = array('123');
     $this->assert(!$tr->save(), "Test->save() should have failed (string name rule should fail)!");
     $tr2 = new Test();
     $tr2->name = '000 second row';
     // three zeroes - to ensure it sorts above the first one
     $this->assert($tr2->save(), 'Test->save() failed: ' . var_export($tr->getErrorList(), 1));
     $s = Test::findAll();
     $s->setOrder('name');
     $s->paginate(1, 1);
     $all = $s->export()->fetchAll();
     $this->assert(1 == count($all), 'Select->count() failed after pagination');
     $this->assert($tr2->name == $all[0]->name, 'Select->export() failed ordering');
 }
开发者ID:nakonechny,项目名称:naf,代码行数:28,代码来源:ActiveRecordTest.php

示例3: testTable

 function testTable()
 {
     $tb = Test::table();
     $new_data = ['nickname' => 'z3'];
     $tb->insert($new_data);
     $this->assertEquals(1, $tb->count());
     $this->assertEquals([['nickname' => 'z3']], $tb->selectData());
     $update = $tb->update(['nickname' => 'w5']);
     $this->assertEquals(1, $update);
     $this->assertEquals([['nickname' => 'w5']], $tb->selectData());
     $tb_new = clone $tb;
     $tb_new->where('nickname=%s', 'w5');
     //$this->assertEquals('SELEC', $tb->buildSelect());
     $this->assertEquals([['nickname' => 'w5']], $tb_new->selectData());
     $tb_new->clearWhere();
     $tb_new->andWhere(['nickname' => 'w5']);
     //$this->assertEquals('SELEC', $tb->buildSelect());
     $this->assertEquals([['nickname' => 'w5']], $tb_new->selectData());
     $this->assertEquals(1, $tb_new->update(['nickname' => 'z3']));
     $this->assertEquals([['nickname' => 'z3']], $tb->selectData());
     $obj_list = $tb->select();
     $obj = $obj_list[0];
     /* @var $obj Test */
     $this->assertEquals('z3', $obj->nickname);
     $tb->delete();
     $test = new Test();
     $test->nickname = 'hehe';
     $this->assertEquals(TRUE, $test->save());
     $this->assertEquals('hehe', Test::table()->selectData()[0]['nickname']);
     $test->delete();
     $this->assertEquals([], $tb->selectData());
     $this->assertEquals('SELECT * FROM test Test', $tb->buildSelect());
     $this->assertEquals('SELECT * FROM test Test LIMIT 10', $tb->buildSelect(10));
     $this->assertEquals('SELECT * FROM test Test LIMIT 10 OFFSET 10', $tb->buildSelect(10, 10));
 }
开发者ID:kasonyang,项目名称:hitar,代码行数:35,代码来源:TableTest.php

示例4: actionAddMessage

 function actionAddMessage($nick, $msg)
 {
     $test = new Test();
     $test->Name = $nick;
     $test->Message = $msg;
     $test->save();
     $this->redirect('/');
 }
开发者ID:angelog,项目名称:nin,代码行数:8,代码来源:index.php

示例5: testConstruct

 /**
  * @covers ::initialize
  */
 public function testConstruct()
 {
     $test = new Test();
     $this->assertNotNull($test->uniqueKey);
     Test::save($test);
     $test2 = new Test();
     $this->assertNotNull($test2->uniqueKey);
     $this->assertNotEquals($test->uniqueKey, $test2->uniqueKey);
 }
开发者ID:harp-orm,项目名称:random-key,代码行数:12,代码来源:RandomKeyTest.php

示例6: create

 /**
  * @before _secure, _admin
  */
 public function create()
 {
     $this->seo(array("title" => "Create Medical Test", "view" => $this->getLayoutView()));
     $view = $this->getActionView();
     if (RequestMethods::post("action") == "medicaltest") {
         $medicaltest = new Test(array("title" => RequestMethods::post("title"), "details" => RequestMethods::post("details"), "reschedule" => RequestMethods::post("reschedule", 50)));
         $medicaltest->save();
         $view->set("success", true);
     }
 }
开发者ID:HLitmus,项目名称:WebApp,代码行数:13,代码来源:medicaltest.php

示例7: addTopicToTest

 function addTopicToTest($id = 1)
 {
     $toc = new Topic();
     $toc->get_by_id($id);
     $t = new Test();
     $t->get_by_id(2);
     if ($t->save($toc)) {
         echo $toc->to_json();
     }
 }
开发者ID:htom78,项目名称:peersay,代码行数:10,代码来源:ormTest.php

示例8: actionCreate

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

示例9: actionTest

 public function actionTest()
 {
     // $tests = Test::model()->findAll();
     // $names="";
     // foreach ($tests as $test)
     //    {
     //   	  $names=$names.$test->name."</br>";
     //    }
     //        $this->render("test",array("names"=>$names));
     //
     $new = new Test();
     $new->name = "imya";
     $new->text = "rrrr";
     $new->save();
 }
开发者ID:bgshechka,项目名称:pos-shop,代码行数:15,代码来源:MainController.php

示例10: actionCreate

 public function actionCreate()
 {
     $model = new Test();
     if (isset($_POST['Test'])) {
         $model->setAttributes($_POST['Test']);
         if ($model->save()) {
             if (Yii::app()->getRequest()->getIsAjaxRequest()) {
                 Yii::app()->end();
             } else {
                 $this->redirect(array('view', 'id' => $model->id));
             }
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:subhra-sekhar,项目名称:yiitest,代码行数:15,代码来源:TestController.php

示例11: Test

 function test_new_and_save()
 {
     setup_sqlite_test_db();
     # Create a dummy test entry, ensure it got its parameters and that it's
     # successfully saved
     $dummy = new Test(array("dummy" => "Test123"));
     $this->assertEqual($dummy->dummy, "Test123");
     $this->assertTrue($dummy->save());
     $this->assertTrue($dummy->id > 0);
     # Return the complete table and check there is exactly one row
     $all_rows = Test::find("all");
     $this->assertEqual(count($all_rows), 1);
     # Return the first row and check it matches our dummy test entry
     $first = Test::find("first");
     $this->assertEqual($first->dummy, "Test123");
     $this->assertTrue($first->id > 0);
 }
开发者ID:kakra,项目名称:adodbrecord,代码行数:17,代码来源:TestTableStorage.class.php

示例12: date

 function post_save($data)
 {
     $sql->null;
     if ($data->id) {
         //update
         $sql = Test::find($data->id);
         //date("d-m-Y H:i:s") date("Y-m-d  H:i:s") tanto faz
         $sql->update_attributes(array('nome' => $data->nome, 'user_id' => $data->user_id, 'updated' => date("Y-m-d  H:i:s")));
     } else {
         //insert
         $attributes = array('nome' => $data->nome, 'user_id' => $data->user_id, 'created' => date("Y-m-d  H:i:s"));
         $sql = new Test($attributes);
     }
     $sql->save();
     $retorno = $sql->to_json();
     return '{"result": [' . $retorno . ']}';
 }
开发者ID:joeymetal,项目名称:restful-sdti,代码行数:17,代码来源:TestController.php

示例13: post_create

 public function post_create()
 {
     $test = new Test();
     $test->description = Input::get('description');
     $test->url = Input::get('url');
     $test->type = Input::get('type');
     $test->user_id = Auth::user()->id;
     $test->options = Input::get('options');
     try {
         if ($test->save()) {
             return Redirect::to_route('test_detail', array($test->id));
         } else {
             return Redirect::to('test/create')->with('error', $test->errors->all())->with_input();
         }
     } catch (Max_Tests_Exceeded_Exception $e) {
         return Redirect::to_route('test_list')->with('error', 'Sorry! You have reached the maximum amount of tests you are allowed.');
     }
 }
开发者ID:netcon-source,项目名称:clementia,代码行数:18,代码来源:test.php

示例14: post_add_test

 public function post_add_test(Test $test)
 {
     if (!$this->bool_has_role) {
         return $this->roleHelper->call_redirect();
     } else {
         $validation_rules = ['category' => 'required|max:50', 'sub_category' => 'required|max:50'];
         $this->validate($request, $validation_rules);
         $arr_test_info = array('category' => $request->category, 'sub_category' => $request->sub_category);
         //    		$user = new User;
         foreach ($arr_test_info as $key => $val) {
             $test->{$key} = $val;
         }
         $test->save();
         $test_id = $test->id;
         // return to raw password for view
         //    		$arr_user_info['password'] = $request->password;
         $data = array('arr_test_info' => $arr_test_info, 'arr_logged_in_user' => $this->arr_logged_in_user);
         return view('test/add_test_results')->with('data', $data);
     }
 }
开发者ID:jenniferbradley49,项目名称:testing_app_two,代码行数:20,代码来源:TestController.php

示例15: actionTest

 public function actionTest()
 {
     $transaction = Yii::app()->db->beginTransaction();
     $errors = [];
     try {
         for ($i = 0; $i < 4; $i++) {
             $test1 = new Test();
             $test1->attributes = ['name' => '10', 'user_id' => '123', 'no' => '123', 'date' => '2015-01-01', 'datetime' => '2015-01-01 10:10:10', 'varchar' => 'oke'];
             $test1->save();
             if ($test1->hasErrors()) {
                 $errors[] = $test1->errors;
             }
         }
         if (empty($errors)) {
             $transaction->commit();
         } else {
             var_dump($errors);
             die;
             $transaction->rollback();
         }
     } catch (Exception $e) {
         $transaction->rollback();
     }
 }
开发者ID:reggi49,项目名称:plansys,代码行数:24,代码来源:ServiceController.php


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