本文整理汇总了PHP中UserModel::objects方法的典型用法代码示例。如果您正苦于以下问题:PHP UserModel::objects方法的具体用法?PHP UserModel::objects怎么用?PHP UserModel::objects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserModel
的用法示例。
在下文中一共展示了UserModel::objects方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCustomeFields
public function testCustomeFields()
{
$q = UserModel::objects()->limit(5)->values(['user_id', 'username']);
foreach ($q as $obj) {
$this->assertCount(2, $obj);
}
}
示例2: testFilterIn3
public function testFilterIn3()
{
$q1 = UserModel::objects()->filter(['user_id__in' => [1, 2, 3, 4, 5]])->valuesList('pk', false);
$q2 = CustomerOrderModel::objects()->filter(['user__in' => $q1]);
$obj = $q2->current();
$this->assertInstanceOf('\\Dja\\Db\\Model\\Model', $obj);
$this->assertContains($obj->user_id, [1, 2, 3, 4, 5]);
}
示例3: testRefresh
public function testRefresh()
{
$obj = UserModel::objects()->get(1);
$initial = $obj->username;
$obj->username = 'testtest';
$obj->refresh();
$this->assertEquals($initial, $obj->username);
}
示例4: testGetOrCreate
public function testGetOrCreate()
{
$obj = UserModel::objects()->getOrCreate(['user_id' => 1]);
$this->assertInstanceOf('\\UserModel', $obj);
$this->assertFalse($obj->isNewRecord());
$obj = UserModel::objects()->getOrCreate(['user_id' => 99999]);
$this->assertInstanceOf('\\UserModel', $obj);
$this->assertTrue($obj->isNewRecord());
}
示例5: testSelectingCached
public function testSelectingCached()
{
$countQ1 = count(SqlLog::$log->queries);
$q = UserModel::objects()->raw('SELECT * FROM :t LIMIT 5');
foreach ($q->cached() as $obj) {
$this->assertInstanceOf('\\Dja\\Db\\Model\\Model', $obj);
}
foreach ($q->cached() as $obj) {
$this->assertInstanceOf('\\Dja\\Db\\Model\\Model', $obj);
}
$countQ2 = count(SqlLog::$log->queries);
$this->assertEquals(1, $countQ2 - $countQ1);
}
示例6: testUsing
public function testUsing()
{
$conn = Dja\Db\Model\Metadata::getDefaultDbConnection();
$q = UserModel::objects()->limit(5)->using($conn);
$q->count();
}
示例7: testBase
public function testBase()
{
$q = UserModel::objects()->filter(['pk__lt' => 10])->limit(1);
$obj = $q->current();
$this->assertEquals($obj->slug, slugify($obj->fullname));
}