本文整理汇总了PHP中Author::table方法的典型用法代码示例。如果您正苦于以下问题:PHP Author::table方法的具体用法?PHP Author::table怎么用?PHP Author::table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Author
的用法示例。
在下文中一共展示了Author::table方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
示例2: 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));
}
示例3: test_delete_with_no_primary_key_defined
/**
* @expectedException ActiveRecord\ActiveRecordException
*/
public function test_delete_with_no_primary_key_defined()
{
Author::table()->pk = array();
$author = author::first();
$author->delete();
}
示例4: testFindByPkShouldNotUseLimit
public function testFindByPkShouldNotUseLimit()
{
Author::find(1);
$this->assertSqlHas('SELECT * FROM authors WHERE author_id=?', Author::table()->lastSql);
}
示例5: 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);
}
示例6: test_find_by_pk_should_not_use_limit
public function test_find_by_pk_should_not_use_limit()
{
Author::find(1);
$this->assert_sql_has('SELECT * FROM authors WHERE author_id=?', Author::table()->last_sql);
}
示例7: test_default_expire
public function test_default_expire()
{
$this->assert_equals(30, Author::table()->cache_model_expire);
}
示例8: test_update_all_with_limit_and_order
public function test_update_all_with_limit_and_order()
{
if (!$this->conn->accepts_limit_and_order_for_update_and_delete()) {
$this->mark_test_skipped('Only MySQL & Sqlite accept limit/order with UPDATE clause');
}
$num_affected = Author::update_all(array('set' => 'parent_author_id = 2', 'limit' => 1, 'order' => 'name asc'));
$this->assert_equals(1, $num_affected);
$this->assert_true(strpos(Author::table()->last_sql, 'ORDER BY name asc LIMIT 1') !== false);
}
示例9: testUpdateAllWithLimitAndOrder
public function testUpdateAllWithLimitAndOrder()
{
if (!$this->conn->acceptsLimitAndOrderForUpdateAndDelete()) {
$this->markTestSkipped('Only MySQL & Sqlite accept limit/order with UPDATE clause');
}
$numAffected = Author::updateAll(array('set' => 'parent_author_id = 2', 'limit' => 1, 'order' => 'name asc'));
$this->assertEquals(1, $numAffected);
$this->assertTrue(strpos(Author::table()->lastSql, 'ORDER BY name asc LIMIT 1') !== false);
}
示例10: testWithOptionArray
/**
* @covers ::with()
*/
public function testWithOptionArray()
{
$b = new SelectBuilder();
$b->root('Article');
$b->with(['blog', 'author'])->select(['*']);
$components = $b->build();
$jc = array(new JoinClause('articles', '_'), (new JoinClause('blogs', 'blog', JoinClause::LEFT))->on('_', 'blog_id', 'blog', 'id'), (new JoinClause('authors', 'author', JoinClause::LEFT))->on('_', 'author_id', 'author', 'id'));
$columns = array('_' => ['columns' => Article::table()->getColumns(), 'resAlias' => ''], 'blog' => ['columns' => Blog::table()->getColumns(), 'resAlias' => 'blog'], 'author' => ['columns' => Author::table()->getColumns(), 'resAlias' => 'author']);
$this->assertEquals($jc, $components['from']);
$this->assertEquals($columns, $components['columns']);
}
示例11: testAddInvolvedTable
public function testAddInvolvedTable()
{
$b = new WhereBuilder();
$b->setRootModel('Blog');
$b->addInvolvedTable('articles.author');
$this->assertEquals('Article', $b->getInvolvedModel('articles'));
$this->assertEquals(Article::table(), $b->getInvolvedTable('articles'));
$jc = (new JoinClause('articles', 'articles'))->on('_', 'id', 'articles', 'blog_id');
$this->assertEquals($jc, $b->getJoinClause('articles'));
$this->assertEquals('Author', $b->getInvolvedModel('articles.author'));
$this->assertEquals(Author::table(), $b->getInvolvedTable('articles.author'));
$jc = (new JoinClause('authors', 'articles.author'))->on('articles', 'author_id', 'articles.author', 'id');
$this->assertEquals($jc, $b->getJoinClause('articles.author'));
}