本文整理汇总了PHP中RedBeanModelDataProvider::getTotalItemCount方法的典型用法代码示例。如果您正苦于以下问题:PHP RedBeanModelDataProvider::getTotalItemCount方法的具体用法?PHP RedBeanModelDataProvider::getTotalItemCount怎么用?PHP RedBeanModelDataProvider::getTotalItemCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedBeanModelDataProvider
的用法示例。
在下文中一共展示了RedBeanModelDataProvider::getTotalItemCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFullNameOnContactsSearchFormSearch
public function testFullNameOnContactsSearchFormSearch()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$_FAKEPOST['Contact'] = array();
$_FAKEPOST['Contact']['fullName'] = 'Jackie Tyler';
$metadataAdapter = new SearchDataProviderMetadataAdapter(new ContactsSearchForm(new Contact(false)), 1, $_FAKEPOST['Contact']);
$searchAttributeData = $metadataAdapter->getAdaptedMetadata();
$compareData = array('clauses' => array(1 => array('attributeName' => 'firstName', 'operatorType' => 'startsWith', 'value' => 'Jackie Tyler'), 2 => array('attributeName' => 'lastName', 'operatorType' => 'startsWith', 'value' => 'Jackie Tyler'), 3 => array('concatedAttributeNames' => array('firstName', 'lastName'), 'operatorType' => 'startsWith', 'value' => 'Jackie Tyler')), 'structure' => '(1 or 2 or 3)');
$this->assertEquals($compareData, $searchAttributeData);
$joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('Contact');
$quote = DatabaseCompatibilityUtil::getQuote();
$where = RedBeanModelDataProvider::makeWhere('Contact', $searchAttributeData, $joinTablesAdapter);
$compareWhere = "(({$quote}person{$quote}.{$quote}firstname{$quote} like 'Jackie Tyler%') or ";
$compareWhere .= "({$quote}person{$quote}.{$quote}lastname{$quote} like 'Jackie Tyler%') or ";
$compareWhere .= "(concat({$quote}person{$quote}.{$quote}firstname{$quote}, ' ', ";
$compareWhere .= "{$quote}person{$quote}.{$quote}lastname{$quote}) like 'Jackie Tyler%'))";
$this->assertEquals($compareWhere, $where);
//Now test that the joinTablesAdapter has correct information.
$this->assertEquals(1, $joinTablesAdapter->getFromTableJoinCount());
$this->assertEquals(0, $joinTablesAdapter->getLeftTableJoinCount());
$fromTables = $joinTablesAdapter->getFromTablesAndAliases();
$this->assertEquals('person', $fromTables[0]['tableName']);
//Make sure the sql runs properly.
$dataProvider = new RedBeanModelDataProvider('Contact', null, false, $searchAttributeData);
$data = $dataProvider->getData();
$this->assertEquals(0, count($data));
ContactTestHelper::createContactByNameForOwner('Dino', $super);
$dataProvider->getTotalItemCount(true);
//refreshes the total item count
$data = $dataProvider->getData();
$this->assertEquals(0, count($data));
ContactTestHelper::createContactByNameForOwner('Jackie', $super);
$dataProvider->getTotalItemCount(true);
//refreshes the total item count
$data = $dataProvider->getData();
$this->assertEquals(0, count($data));
ContactsModule::loadStartingData();
$contact = new Contact();
$contact->firstName = 'Jackie';
$contact->lastName = 'Tyler';
$contact->owner = $super;
$contact->state = ContactsUtil::getStartingState();
$this->assertTrue($contact->save());
$dataProvider->getTotalItemCount(true);
//refreshes the total item count
$data = $dataProvider->getData(true);
$this->assertEquals(1, count($data));
$this->assertEquals($contact->id, $data[0]->id);
}