本文整理匯總了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);
}