本文整理匯總了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";
}
示例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()));
}
示例3: test_getter
public function test_getter()
{
$book = Book::first();
$this->assert_equals(strtoupper($book->name), $book->upper_name);
}
示例4: testDirtyAttributesWithMassAssignment
public function testDirtyAttributesWithMassAssignment()
{
$book = Book::first();
$book->setAttributes(array('name' => 'rivers cuomo'));
$this->assertEquals(array('name'), array_keys($book->dirtyAttributes()));
}
示例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());
示例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');
}