本文整理汇总了PHP中Author::first方法的典型用法代码示例。如果您正苦于以下问题:PHP Author::first方法的具体用法?PHP Author::first怎么用?PHP Author::first使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Author
的用法示例。
在下文中一共展示了Author::first方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_regular_models_not_cached
public function test_regular_models_not_cached()
{
$method = $this->set_method_public('Author', 'cache_key');
$author = Author::first();
$cache_key = $method->invokeArgs($author, array());
$this->assertFalse(Cache::$adapter->read($cache_key));
}
示例2: test_caches_column_meta_data
public function test_caches_column_meta_data()
{
Author::first();
$table_name = Author::table()->get_fully_qualified_table_name(!$this->conn instanceof ActiveRecord\PgsqlAdapter);
$value = Cache::$adapter->read("get_meta_data-{$table_name}");
$this->assert_true(is_array($value));
}
示例3: testCachesColumnMetaData
public function testCachesColumnMetaData()
{
Author::first();
$tableName = Author::table()->getFullyQualifiedTableName(!$this->conn instanceof ActiveRecord\PgsqlAdapter);
$value = Cache::$adapter->read("get_meta_data-{$tableName}");
$this->assertTrue(is_array($value));
}
示例4: test_datefield_gets_converted_to_ar_datetime
public function test_datefield_gets_converted_to_ar_datetime()
{
//make sure first author has a date
$author = Author::first();
$author->some_date = new DateTime();
$author->save();
$author = Author::first();
$this->assert_is_a("ActiveRecord\\DateTime", $author->some_date);
}
示例5: test_has_many_build_association
public function test_has_many_build_association()
{
$author = Author::first();
$this->assert_equals($author->id, $author->build_books()->author_id);
$this->assert_equals($author->id, $author->build_book()->author_id);
}
示例6: test_is_dirty
public function test_is_dirty()
{
$author = Author::first();
$this->assert_equals(false, $author->is_dirty());
$author->name = 'coco';
$this->assert_equals(true, $author->is_dirty());
}
示例7: testHaving
public function testHaving()
{
if ($this->conn instanceof ActiveRecord\OciAdapter) {
$author = Author::first(array('select' => 'to_char(created_at,\'YYYY-MM-DD\') as created_at', 'group' => 'to_char(created_at,\'YYYY-MM-DD\')', 'having' => "to_char(created_at,'YYYY-MM-DD') > '2009-01-01'"));
$this->assertSqlHas("GROUP BY to_char(created_at,'YYYY-MM-DD') HAVING to_char(created_at,'YYYY-MM-DD') > '2009-01-01'", Author::table()->lastSql);
} else {
$author = Author::first(array('select' => 'date(created_at) as created_at', 'group' => 'date(created_at)', 'having' => "date(created_at) > '2009-01-01'"));
$this->assertSqlHas("GROUP BY date(created_at) HAVING date(created_at) > '2009-01-01'", Author::table()->lastSql);
}
}
示例8: test_having
public function test_having()
{
$author = Author::first(array('group' => "date(created_at)", 'having' => "created_at > '2009-01-01'"));
$this->assert_true(strpos(Author::table()->last_sql, "GROUP BY date(created_at) HAVING created_at > '2009-01-01'") !== false);
}
示例9: test_only_method
public function test_only_method()
{
$this->assert_contains('<sharks>lasers</sharks>', Author::first()->to_xml(array('only_method' => 'return_something')));
}
示例10: test_undefined_instance_method
/**
* @expectedException ActiveRecord\ActiveRecordException
*/
public function test_undefined_instance_method()
{
Author::first()->find_by_name('sdf');
}
示例11: testOnlyMethod
public function testOnlyMethod()
{
$this->assertContains('<sharks>lasers</sharks>', Author::first()->toXml(array('onlyMethod' => 'returnSomething')));
}
示例12: testHasManyBuildAssociation
public function testHasManyBuildAssociation()
{
$author = Author::first();
$this->assertEquals($author->id, $author->buildBooks()->author_id);
$this->assertEquals($author->id, $author->buildBook()->author_id);
}
示例13: test_has_one_can_be_self_referential
public function test_has_one_can_be_self_referential()
{
Author::$has_one[1] = array('parent_author', 'class_name' => 'Author', 'foreign_key' => 'parent_author_id');
$author = Author::first();
$this->assert_equals(1, $author->id);
$this->assert_equals(3, $author->parent_author->id);
}
示例14: testUndefinedInstanceMethod
/**
* @expectedException ActiveRecord\ActiveRecordException
*/
public function testUndefinedInstanceMethod()
{
Author::first()->findByName('sdf');
}