本文整理汇总了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');
}