當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserModel::objects方法代碼示例

本文整理匯總了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);
     }
 }
開發者ID:buldezir,項目名稱:dja_orm,代碼行數:7,代碼來源:ValuesQuerySetTest.php

示例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]);
 }
開發者ID:buldezir,項目名稱:dja_orm,代碼行數:8,代碼來源:LookupTest.php

示例3: testRefresh

 public function testRefresh()
 {
     $obj = UserModel::objects()->get(1);
     $initial = $obj->username;
     $obj->username = 'testtest';
     $obj->refresh();
     $this->assertEquals($initial, $obj->username);
 }
開發者ID:buldezir,項目名稱:dja_orm,代碼行數:8,代碼來源:ModelTest.php

示例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());
 }
開發者ID:buldezir,項目名稱:dja_orm,代碼行數:9,代碼來源:ManagerTest.php

示例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);
 }
開發者ID:buldezir,項目名稱:dja_orm,代碼行數:13,代碼來源:RawQuerySetTest.php

示例6: testUsing

 public function testUsing()
 {
     $conn = Dja\Db\Model\Metadata::getDefaultDbConnection();
     $q = UserModel::objects()->limit(5)->using($conn);
     $q->count();
 }
開發者ID:buldezir,項目名稱:dja_orm,代碼行數:6,代碼來源:QuerySetTest.php

示例7: testBase

 public function testBase()
 {
     $q = UserModel::objects()->filter(['pk__lt' => 10])->limit(1);
     $obj = $q->current();
     $this->assertEquals($obj->slug, slugify($obj->fullname));
 }
開發者ID:buldezir,項目名稱:dja_orm,代碼行數:6,代碼來源:SlugTest.php


注:本文中的UserModel::objects方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。