當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Library::save方法代碼示例

本文整理匯總了PHP中Library::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP Library::save方法的具體用法?PHP Library::save怎麽用?PHP Library::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Library的用法示例。


在下文中一共展示了Library::save方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: handleCreate

 public function handleCreate()
 {
     //get file path
     Input::file('file_img')->move(public_path() . '/img/', Input::file('file_img')->getClientOriginalName());
     $book = new Library();
     $book->book_name = Input::get('book_name');
     $book->book_copy = Input::get('copy');
     $book->book_img_name = Input::file('file_img')->getClientOriginalName();
     $book->created_by_id = Auth::id();
     $book->updated_by_id = Auth::id();
     $book->save();
     return Redirect::action('AdminLibraryController@index')->with('flash_edit_success', 'Hurray!You have added a new Book');
 }
開發者ID:BDMADE,項目名稱:DBA,代碼行數:13,代碼來源:AdminLibraryController.php

示例2: testManyToMany

 public function testManyToMany()
 {
     $library = new Library();
     $library->setName('Travis County Reader');
     $library->save();
     $library2 = new Library();
     $library2->setName('LBJ Center');
     $library2->save();
     $author = new Author();
     $author->setName('Haruki Murakami');
     $book = new Book();
     $book->setTitle('Norwegian Wood');
     $book->save();
     $book2 = new Book();
     $book2->setTitle('Kafka on the Shore');
     $book2->save();
     $author->addBook($book);
     $author->addBook($book2);
     $author->save();
     $book2library = new Book2library();
     $book2library->setBookId($book->getBookId());
     $book2library->setLibraryId($library->getLibraryId());
     $book2library->save();
     $book2library2 = new Book2library();
     $book2library2->setBookId($book2->getBookId());
     $book2library2->setLibraryId($library->getLibraryId());
     $book2library2->save();
     $book2library3 = new Book2library();
     $book2library3->setBookId($book->getBookId());
     $book2library3->setLibraryId($library2->getLibraryId());
     $book2library3->save();
     $book2library4 = new Book2library();
     $book2library4->setBookId($book2->getBookId());
     $book2library4->setLibraryId($library2->getLibraryId());
     $book2library4->save();
     // now both books should be in both libraries
     $sameLibrary = Library::constructByKey($library->getLibraryId());
     $bookJoinsInTravis = $sameLibrary->getBook2library_Collection();
     // $this->dump($bookJoinsInTravis);
     $this->assertEqual(count($bookJoinsInTravis), 2);
     // This test is similar to the 4 that are commented out below, but this shows what is different
     // AND it ignores the creation_datetime and last_modified_datetime differences b/c they are
     // intentionally not autoloaded after a save. Just manually call load() after save if you want
     // to get the updated data.
     $mismatches = $this->getFieldMismatches($bookJoinsInTravis->getPosition(0)->getBook_Object(), $book);
     // Unset mistmatches that we know to be intentional
     if (isset($mismatches['creation_datetime'])) {
         unset($mismatches['creation_datetime']);
     }
     if (isset($mismatches['last_modified_datetime'])) {
         unset($mismatches['last_modified_datetime']);
     }
     $this->assertTrue(empty($mismatches), implode("\n", $mismatches));
     // these fail because the $book and $book2 don't have some default values set after save like creation_datetime
     // (which is intentional; call load() after save if you want to get the updated data.)
     // $this->assertIdentical($bookJoinsInTravis->getPosition(0)->getBook_Object(), $book);
     // $this->assertIdentical($bookJoinsInTravis->getPosition(1)->getBook_Object(), $book2);
     $this->assertEqual($bookJoinsInTravis->getPosition(0)->getBook_Object()->getBookId(), $book->getBookId());
     $this->assertEqual($bookJoinsInTravis->getPosition(1)->getBook_Object()->getBookId(), $book2->getBookId());
     $sameLibrary2 = Library::constructByKey($library2->getLibraryId());
     $bookJoinsInLbj = $sameLibrary2->getBook2library_Collection();
     $this->assertEqual(count($bookJoinsInLbj), 2);
     // these fail because the $book and $book2 don't have some default values set after save like creation_datetime
     // (which is intentional; call load() after save if you want to get the updated data.)
     // $this->assertIdentical($bookJoinsInLbj->getPosition(0)->getBook_Object(), $book);
     // $this->assertIdentical($bookJoinsInLbj->getPosition(1)->getBook_Object(), $book2);
     $this->assertEqual($bookJoinsInLbj->getPosition(0)->getBook_Object()->getBookId(), $book->getBookId());
     $this->assertEqual($bookJoinsInLbj->getPosition(1)->getBook_Object()->getBookId(), $book2->getBookId());
 }
開發者ID:jmhobbs,項目名稱:MkLst,代碼行數:69,代碼來源:TestCoughObject.class.php

示例3: doUpload

 private function doUpload()
 {
     if (!empty($_FILES)) {
         $file = $_FILES['uploaded'];
         $file_name = clean_filename($file['name']);
         // TODO: mettre le dosser d'upload dans des configs
         $path = '/uploads/' . date('Y') . '/' . date('m');
         $full_path = $path . '/' . duplicate_filename(ROOT . '/www/' . $path, $file_name);
         $to_path = ROOT . '/www/' . $full_path;
         @mkdir(dirname($to_path), 0755, true);
         move_uploaded_file($file['tmp_name'], $to_path);
         if (isset($_POST['name']) && $_POST['name']) {
             $name = $_POST['name'];
         } else {
             $name = InflectionComponent::humanize(preg_replace('~\\.(.*?)$~', '', $file['name']));
         }
         $info = getimagesize($to_path);
         $File = new Library();
         $File['name'] = $name;
         $File['path'] = $full_path;
         $File['width'] = $info[0];
         $File['height'] = $info[1];
         $File['type'] = $info['mime'];
         $File->save();
         return $File['id'];
     }
 }
開發者ID:nicolasmartin,項目名稱:framework,代碼行數:27,代碼來源:Library.php


注:本文中的Library::save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。