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


PHP Contest::save方法代码示例

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


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

示例1: createContest

 static function createContest($data)
 {
     require_once "common.php";
     $data = Filter::filterArray($data);
     $c = new Contest($data);
     $c->save();
     return $c;
 }
开发者ID:Esisto,项目名称:IoEsisto,代码行数:8,代码来源:common.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 Contest();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Contest'])) {
         $model->attributes = $_POST['Contest'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:RSol,项目名称:yupe,代码行数:17,代码来源:DefaultController.php

示例3: testDefaultExpresions_ReloadOnInsert_Override

 /**
  * Tests the overriding reloadOnInsert at runtime.
  *
  * @link       http://trac.propelorm.org/ticket/378
  * @link       http://trac.propelorm.org/ticket/555
  */
 public function testDefaultExpresions_ReloadOnInsert_Override()
 {
     if (Propel::getDb(BookstoreEmployeePeer::DATABASE_NAME) instanceof DBSqlite) {
         $this->markTestSkipped("Cannot test default date expressions with SQLite");
     }
     // Create a new bookstore, contest, bookstore_contest, and bookstore_contest_entry
     $b = new Bookstore();
     $b->setStoreName("Barnes & Noble");
     $b->save();
     $c = new Contest();
     $c->setName("Bookathon Contest");
     $c->save();
     $bc = new BookstoreContest();
     $bc->setBookstore($b);
     $bc->setContest($c);
     $bc->save();
     $c = new Customer();
     $c->setName("Happy Customer");
     $c->save();
     $bce = new BookstoreContestEntry();
     $bce->setBookstore($b);
     $bce->setBookstoreContest($bc);
     $bce->setCustomer($c);
     $bce->save(null, $skipReload = true);
     $this->assertNull($bce->getEntryDate(), "Expected a NULL entry_date after save.");
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:32,代码来源:GeneratedObjectTest.php

示例4: testMultiColJoin

 /**
  * Testing foreign keys with multiple referrer columns.
  * @link       http://propel.phpdb.org/trac/ticket/606
  */
 public function testMultiColJoin()
 {
     BookstoreContestPeer::doDeleteAll();
     BookstoreContestEntryPeer::doDeleteAll();
     $bs = new Bookstore();
     $bs->setStoreName("Test1");
     $bs->setPopulationServed(5);
     $bs->save();
     $bs1Id = $bs->getId();
     $bs2 = new Bookstore();
     $bs2->setStoreName("Test2");
     $bs2->setPopulationServed(5);
     $bs2->save();
     $bs2Id = $bs2->getId();
     $ct1 = new Contest();
     $ct1->setName("Contest1!");
     $ct1->save();
     $ct1Id = $ct1->getId();
     $ct2 = new Contest();
     $ct2->setName("Contest2!");
     $ct2->save();
     $ct2Id = $ct2->getId();
     $cmr = new Customer();
     $cmr->setName("Customer1");
     $cmr->save();
     $cmr1Id = $cmr->getId();
     $cmr2 = new Customer();
     $cmr2->setName("Customer2");
     $cmr2->save();
     $cmr2Id = $cmr2->getId();
     $contest = new BookstoreContest();
     $contest->setBookstoreId($bs1Id);
     $contest->setContestId($ct1Id);
     $contest->save();
     $contest = new BookstoreContest();
     $contest->setBookstoreId($bs2Id);
     $contest->setContestId($ct1Id);
     $contest->save();
     $entry = new BookstoreContestEntry();
     $entry->setBookstoreId($bs1Id);
     $entry->setContestId($ct1Id);
     $entry->setCustomerId($cmr1Id);
     $entry->save();
     $entry = new BookstoreContestEntry();
     $entry->setBookstoreId($bs1Id);
     $entry->setContestId($ct1Id);
     $entry->setCustomerId($cmr2Id);
     $entry->save();
     // Note: this test isn't really working very well.  We setup fkeys that
     // require that the BookstoreContest rows exist and then try to violate
     // the rules ... :-/  This may work in some lenient databases, but an error
     // is expected here.
     /*
      * Commented out for now ... though without it, this test may not really be testing anything
     $entry = new BookstoreContestEntry();
     $entry->setBookstoreId($bs1Id);
     $entry->setContestId($ct2Id);
     $entry->setCustomerId($cmr2Id);
     $entry->save();
     */
     $c = new Criteria();
     $c->addJoin(array(BookstoreContestEntryPeer::BOOKSTORE_ID, BookstoreContestEntryPeer::CONTEST_ID), array(BookstoreContestPeer::BOOKSTORE_ID, BookstoreContestPeer::CONTEST_ID));
     $results = BookstoreContestEntryPeer::doSelect($c);
     $this->assertEquals(2, count($results));
     foreach ($results as $result) {
         $this->assertEquals($bs1Id, $result->getBookstoreId());
         $this->assertEquals($ct1Id, $result->getContestId());
     }
 }
开发者ID:RafalFilipek,项目名称:Propel2,代码行数:73,代码来源:GeneratedPeerDoSelectTest.php

示例5: testDoDelete_Cascade_CompositePK

 /**
  * Test that cascading deletes are happening correctly for composite pk.
  * @link       http://propel.phpdb.org/trac/ticket/544
  */
 public function testDoDelete_Cascade_CompositePK()
 {
     $origBceCount = BookstoreContestEntryPeer::doCount(new Criteria());
     $cust1 = new Customer();
     $cust1->setName("Cust1");
     $cust1->save();
     $cust2 = new Customer();
     $cust2->setName("Cust2");
     $cust2->save();
     $c1 = new Contest();
     $c1->setName("Contest1");
     $c1->save();
     $c2 = new Contest();
     $c2->setName("Contest2");
     $c2->save();
     $store1 = new Bookstore();
     $store1->setStoreName("Store1");
     $store1->save();
     $bc1 = new BookstoreContest();
     $bc1->setBookstore($store1);
     $bc1->setContest($c1);
     $bc1->save();
     $bc2 = new BookstoreContest();
     $bc2->setBookstore($store1);
     $bc2->setContest($c2);
     $bc2->save();
     $bce1 = new BookstoreContestEntry();
     $bce1->setEntryDate("now");
     $bce1->setCustomer($cust1);
     $bce1->setBookstoreContest($bc1);
     $bce1->save();
     $bce2 = new BookstoreContestEntry();
     $bce2->setEntryDate("now");
     $bce2->setCustomer($cust1);
     $bce2->setBookstoreContest($bc2);
     $bce2->save();
     // Now, if we remove $bc1, we expect *only* bce1 to be no longer valid.
     BookstoreContestPeer::doDelete($bc1);
     $newCount = BookstoreContestEntryPeer::doCount(new Criteria());
     $this->assertEquals($origBceCount + 1, $newCount, "Expected new number of rows in BCE to be orig + 1");
     $bcetest = BookstoreContestEntryPeer::retrieveByPK($store1->getId(), $c1->getId(), $cust1->getId());
     $this->assertNull($bcetest, "Expected BCE for store1 to be cascade deleted.");
     $bcetest2 = BookstoreContestEntryPeer::retrieveByPK($store1->getId(), $c2->getId(), $cust1->getId());
     $this->assertNotNull($bcetest2, "Expected BCE for store2 to NOT be cascade deleted.");
 }
开发者ID:ketheriel,项目名称:ETVA,代码行数:49,代码来源:GeneratedPeerDoDeleteTest.php

示例6: testMultiFkImplication

 /**
  * Test behavior of columns that are implicated in multiple foreign keys.
  * @link       http://propel.phpdb.org/trac/ticket/228
  */
 public function testMultiFkImplication()
 {
     BookstoreDataPopulator::populate();
     // Create a new bookstore, contest, bookstore_contest, and bookstore_contest_entry
     $b = new Bookstore();
     $b->setStoreName("Foo!");
     $b->save();
     $c = new Contest();
     $c->setName("Bookathon Contest");
     $c->save();
     $bc = new BookstoreContest();
     $bc->setBookstore($b);
     $bc->setContest($c);
     $bc->save();
     $c = new Customer();
     $c->setName("Happy Customer");
     $c->save();
     $bce = new BookstoreContestEntry();
     $bce->setBookstore($b);
     $bce->setBookstoreContest($bc);
     $bce->setCustomer($c);
     $bce->save();
     $bce->setBookstoreId(null);
     $this->assertNull($bce->getBookstoreContest());
     $this->assertNull($bce->getBookstore());
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:30,代码来源:GeneratedObjectRelTest.php

示例7: store

 /**
  * Store a newly created contest in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Contest::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     } else {
         $date = new \DateTime();
         $jenjang = Sentry::getUser()->last_name;
         $age = date('Y') - date('Y', strtotime(input::get('tgllhr')));
         // $tahun = \Carbon\Carbon::now();
         if ($jenjang == 'SMA' and $age > 17) {
             return Redirect::back()->withErrors('Umur melebihi batas maksimal')->withInput();
         }
         if ($jenjang == 'SMP' and $age > 14) {
             return Redirect::back()->withErrors('Umur melebihi batas maksimal')->withInput();
         }
         if ($jenjang == 'SD' and $age > 11) {
             return Redirect::back()->withErrors('Umur melebihi batas maksimal')->withInput();
         }
         // isi field cover jika ada cover yang diupload
         if (Input::hasFile('foto') and Input::hasFile('rapor')) {
             $uploaded_file = Input::file('foto');
             $uploaded_rapor = Input::file('rapor');
             // mengambil extension file
             $extension = $uploaded_file->getClientOriginalExtension();
             $extension_rapor = $uploaded_rapor->getClientOriginalExtension();
             // membuat nama file random dengan extension
             $filename = Input::get('nis') . '.' . $extension;
             $filename_rapor = Input::get('nis') . '.' . $extension_rapor;
             $destinationPath = public_path() . DIRECTORY_SEPARATOR . 'uploads/foto';
             $destinationPath_rapor = public_path() . DIRECTORY_SEPARATOR . 'uploads/rapor';
             // memindahkan file ke folder public/img
             $uploaded_file->move($destinationPath, $filename);
             // 25
             $uploaded_rapor->move($destinationPath_rapor, $filename_rapor);
             // 25
             $contest = new Contest();
             $contest->nocontest = input::get('nocontest');
             $contest->verifikasi = '0';
             $contest->name = input::get('name');
             $contest->nis = input::get('nis');
             $contest->tmptlhr = input::get('tmptlhr');
             $contest->tgllhr = input::get('tgllhr');
             $contest->tahun = date('Y');
             $contest->nodada = '';
             $contest->juara = '-';
             $contest->jenjang = Sentry::getUser()->last_name;
             $contest->foto = $filename;
             $contest->rapor = $filename_rapor;
             $contest->user_id = Sentry::getUser()->id;
             $contest->sertifikat = Input::has('sertifikat') ? true : false;
             $contest->created_at = $date;
             $contest->updated_at = $date;
             $contest->save();
             return Redirect::route('user.contests.index')->with("successMessage", "Formulir berhasil disimpan");
         } else {
             return Redirect::back()->withErrors('File Foto dan/atau Rapor tidak ada')->withInput();
         }
         //Kerja::create($data);
     }
 }
开发者ID:inseo201,项目名称:atletik4,代码行数:66,代码来源:ContestsController.php


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