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


PHP Book::first方法代碼示例

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


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

示例1: crudDelete

 public function crudDelete()
 {
     # Get a book to delete
     $book = Book::first();
     # Delete the book
     $book->delete();
     echo "This book has been deleted";
 }
開發者ID:rebekahheacock,項目名稱:dwa15-archive,代碼行數:8,代碼來源:DemoController.php

示例2: test_dirty_attributes_with_mass_assignment

 public function test_dirty_attributes_with_mass_assignment()
 {
     $book = Book::first();
     $book->set_attributes(array('name' => 'rivers cuomo'));
     $this->assert_equals(array('name'), array_keys($book->dirty_attributes()));
 }
開發者ID:J1Duran,項目名稱:ph-web,代碼行數:6,代碼來源:ActiveRecordWriteTest.php

示例3: test_getter

 public function test_getter()
 {
     $book = Book::first();
     $this->assert_equals(strtoupper($book->name), $book->upper_name);
 }
開發者ID:sebcode,項目名稱:php-activerecord,代碼行數:5,代碼來源:ActiveRecordTest.php

示例4: testDirtyAttributesWithMassAssignment

 public function testDirtyAttributesWithMassAssignment()
 {
     $book = Book::first();
     $book->setAttributes(array('name' => 'rivers cuomo'));
     $this->assertEquals(array('name'), array_keys($book->dirtyAttributes()));
 }
開發者ID:ruri,項目名稱:php-activerecord-camelcased,代碼行數:6,代碼來源:ActiveRecordWriteTest.php

示例5: dirname

<?php

require_once dirname(__FILE__) . '/../../ActiveRecord.php';
// assumes a table named "books" with a pk named "id"
// see simple.sql
class Book extends ActiveRecord\Model
{
}
// initialize ActiveRecord
// change the connection settings to whatever is appropriate for your mysql server
ActiveRecord\Config::initialize(function ($cfg) {
    $cfg->set_model_directory('.');
    $cfg->set_connections(array('development' => 'mysql://test:test@127.0.0.1/test'));
});
print_r(Book::first()->attributes());
開發者ID:aslijiasheng,項目名稱:jacksonslim,代碼行數:15,代碼來源:simple.php

示例6: test_readonly_only_halt_on_write_method

 public function test_readonly_only_halt_on_write_method()
 {
     $book = Book::first(array('readonly' => true));
     $this->assert_true($book->is_readonly());
     try {
         $book->save();
         $this - fail('expected exception ActiveRecord\\ReadonlyException');
     } catch (ActiveRecord\ReadonlyException $e) {
     }
     $book->name = 'some new name';
     $this->assert_equals($book->name, 'some new name');
 }
開發者ID:scorplev,項目名稱:php-activerecord,代碼行數:12,代碼來源:ActiveRecordTest.php


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