当前位置: 首页>>代码示例>>PHP>>正文


PHP Account::getSubset方法代码示例

本文整理汇总了PHP中Account::getSubset方法的典型用法代码示例。如果您正苦于以下问题:PHP Account::getSubset方法的具体用法?PHP Account::getSubset怎么用?PHP Account::getSubset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Account的用法示例。


在下文中一共展示了Account::getSubset方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getAccountsByPartialName

 /**
  * For a given partialName, run search by partial name and retrieve account models.
  * @param string $partialName
  * @param null|int $pageSize
  */
 public static function getAccountsByPartialName($partialName, $pageSize = null)
 {
     assert('is_string($partialName)');
     $metadata = array();
     $metadata['clauses'] = array(1 => array('attributeName' => 'name', 'operatorType' => 'contains', 'value' => $partialName));
     $metadata['structure'] = '1';
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('Account');
     $where = RedBeanModelDataProvider::makeWhere('Account', $metadata, $joinTablesAdapter);
     return Account::getSubset($joinTablesAdapter, null, $pageSize, $where);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:15,代码来源:AccountSearch.php

示例2: getAccountsByAnyEmailAddress

 /**
  * For a given email address, run search by email address and retrieve account models.
  */
 public static function getAccountsByAnyEmailAddress($emailAddress, $pageSize = null)
 {
     assert('is_string($emailAddress)');
     $metadata = array();
     $metadata['clauses'] = array(1 => array('attributeName' => 'primaryEmail', 'relatedAttributeName' => 'emailAddress', 'operatorType' => 'equals', 'value' => $emailAddress), 2 => array('attributeName' => 'secondaryEmail', 'relatedAttributeName' => 'emailAddress', 'operatorType' => 'equals', 'value' => $emailAddress));
     $metadata['structure'] = '(1 or 2)';
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('Account');
     $where = RedBeanModelDataProvider::makeWhere('Account', $metadata, $joinTablesAdapter);
     return Account::getSubset($joinTablesAdapter, null, $pageSize, $where);
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:13,代码来源:AccountSearch.php

示例3: nukeExistingAccounts

 protected function nukeExistingAccounts()
 {
     while (true) {
         $accounts = Account::getSubset(null, 0, 50);
         // Nuke 50 at a time to
         if (count($accounts) == 0) {
             // we get to the big numbers.
             break;
         }
         foreach ($accounts as $account) {
             $account->delete();
             unset($account);
         }
         unset($accounts);
     }
     $this->assertEquals(0, Account::getCount());
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:17,代码来源:AccountReadPermissionsOptimizationBaseTest.php

示例4: disabled_testAShootLoadOfAccounts

 public function disabled_testAShootLoadOfAccounts()
 {
     $super = User::getByUsername('super');
     foreach (array(20, 50, 100, 200, 500, 1000, 10000, 100000, 200000) as $shootLoad) {
         echo "\nNuking existing accounts...\n";
         Yii::app()->user->userModel = $super;
         $this->nukeExistingAccounts();
         echo "Creating {$shootLoad} accounts...\n";
         echo " - Giving every 10th to Betty, giving Benny read\n";
         echo "   on overy 8th, and giving Sales Staff read on\n";
         echo "   every 12th.\n";
         list($time, $countThatBennyCanRead, $accountIdsThatBennyCanRead) = $this->createAccounts($shootLoad);
         echo 'Created accounts in ' . round($time, 1) . " seconds.\n";
         echo "Benny can read {$countThatBennyCanRead} of them.\n";
         echo 'The first few... ';
         for ($i = 0; $i < 10 && $i < count($accountIdsThatBennyCanRead); $i++) {
             echo "{$accountIdsThatBennyCanRead[$i]}|";
         }
         echo "\n";
         $startTime = microtime(true);
         ReadPermissionsOptimizationUtil::rebuild(true, true);
         $endTime = microtime(true);
         if ($this->isDebug()) {
             echo 'Rebuilt the munge in php in ' . round($endTime - $startTime, 1) . ' seconds, ' . self::getAccountMungeRowCount() . " rows.\n";
         }
         $phpRows = ZurmoRedBean::getAll('select munge_id, securableitem_id, count from account_read order by munge_id, securableitem_id, count');
         // If $securityOptimized is false in debug.php the second one will just do the php again.
         $startTime = microtime(true);
         ReadPermissionsOptimizationUtil::rebuild();
         $endTime = microtime(true);
         if ($this->isDebug()) {
             echo 'Rebuilt the munge ' . (SECURITY_OPTIMIZED ? 'optimized' : 'in php') . ' in ' . round($endTime - $startTime, 1) . ' seconds, ' . self::getAccountMungeRowCount() . " rows.\n";
         }
         $otherRows = ZurmoRedBean::getAll('select munge_id, securableitem_id, count from account_read order by munge_id, securableitem_id, count');
         if (count(array_diff($phpRows, $otherRows)) > 0) {
             echo "PHP & optimized munges don't match.\n";
             echo "--------\n";
             foreach ($phpRows as $row) {
                 echo join(', ', array_values($row)) . "\n";
             }
             echo "--------\n";
             foreach ($otherRows as $row) {
                 echo join(', ', array_values($row)) . "\n";
             }
             echo "--------\n";
         }
         $this->assertEquals(count($phpRows), count($otherRows));
         $this->assertEquals($phpRows, $otherRows);
         Yii::app()->user->userModel = User::getByUsername('benny');
         $count = Account::getCount();
         $startTime = microtime(true);
         $accounts = Account::getSubset(null, 0, 20);
         $endTime = microtime(true);
         echo 'As Benny retrieved 1 - ' . count($accounts) . " of {$count} in " . round($endTime - $startTime, 2) . " seconds.\n";
         unset($accounts);
         $offset = intval($count * 0.75);
         $startTime = microtime(true);
         $accounts = Account::getSubset(null, $offset, 20);
         $endTime = microtime(true);
         echo "As Benny retrieved {$offset} - " . ($offset + count($accounts)) . " of {$count} in " . round($endTime - $startTime, 3) . " seconds.\n";
         unset($accounts);
         echo "Done.\n";
         echo "\n-------------------------------\n";
     }
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:65,代码来源:AccountReadPermissionsOptimizationTest.php

示例5: testAllCustomAttributesAdaptToMetadataFromPostCorrectly

 /**
  * @depends testAllNullValuedCustomAttributesAdaptToMetadataFromPostCorrectly
  */
 public function testAllCustomAttributesAdaptToMetadataFromPostCorrectly()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     //Account Model - Fake post with all custom attribute types that they adapt correct to metadata.
     $fakePostData = array('checkBoxCstm' => array('value' => '1'), 'currencyCstm' => '108.45', 'dateCstm' => '2007-07-01', 'dateTimeCstm' => '2007-07-01 06:12:45', 'decimalCstm' => '45.6', 'dropDownCstm' => array('value' => '3'), 'integerCstm' => '67876', 'phoneCstm' => '123456', 'radioCstm' => array('value' => '2'), 'textCstm' => 'Some Text', 'textAreaCstm' => 'Some description', 'urlCstm' => 'somesite.com');
     $metadataAdapter = new SearchDataProviderMetadataAdapter(new Account(), $super->id, $fakePostData);
     $searchAttributeData = $metadataAdapter->getAdaptedMetadata();
     $compareClauses = array(1 => array('attributeName' => 'checkBoxCstm', 'operatorType' => 'equals', 'value' => (bool) 1), 2 => array('attributeName' => 'currencyCstm', 'operatorType' => 'equals', 'value' => (double) 108.45), 3 => array('attributeName' => 'dateCstm', 'operatorType' => 'equals', 'value' => '2007-07-01'), 4 => array('attributeName' => 'dateTimeCstm', 'operatorType' => 'equals', 'value' => '2007-07-01 06:12:45'), 5 => array('attributeName' => 'decimalCstm', 'operatorType' => 'equals', 'value' => (double) 45.6), 6 => array('attributeName' => 'dropDownCstm', 'relatedAttributeName' => 'value', 'operatorType' => 'equals', 'value' => '3'), 7 => array('attributeName' => 'integerCstm', 'operatorType' => 'equals', 'value' => (int) 67876), 8 => array('attributeName' => 'phoneCstm', 'operatorType' => 'startsWith', 'value' => '123456'), 9 => array('attributeName' => 'radioCstm', 'relatedAttributeName' => 'value', 'operatorType' => 'equals', 'value' => '2'), 10 => array('attributeName' => 'textCstm', 'operatorType' => 'startsWith', 'value' => 'Some Text'), 11 => array('attributeName' => 'textAreaCstm', 'operatorType' => 'contains', 'value' => 'Some description'), 12 => array('attributeName' => 'urlCstm', 'operatorType' => 'contains', 'value' => 'somesite.com'));
     $compareStructure = '1 and 2 and 3 and 4 and 5 and 6 and 7 and 8 and 9 and 10 and 11 and 12';
     $this->assertEquals($compareClauses, $searchAttributeData['clauses']);
     $this->assertEquals($compareStructure, $searchAttributeData['structure']);
     //Build the query 'where' and 'joins'. Confirm they are as expected
     $quote = DatabaseCompatibilityUtil::getQuote();
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('Account');
     $where = RedBeanModelDataProvider::makeWhere('Account', $searchAttributeData, $joinTablesAdapter);
     $compareWhere = "({$quote}account{$quote}.{$quote}checkboxcstm{$quote} = 1)" . " and ({$quote}account{$quote}.{$quote}currencycstm_currencyvalue_id{$quote} = 108.45)" . " and ({$quote}account{$quote}.{$quote}datecstm{$quote} = '2007-07-01')" . " and ({$quote}account{$quote}.{$quote}datetimecstm{$quote} = '2007-07-01 06:12:45')" . " and ({$quote}account{$quote}.{$quote}decimalcstm{$quote} = 45.6)" . " and ({$quote}customfield{$quote}.{$quote}value{$quote} = '3')" . " and ({$quote}account{$quote}.{$quote}integercstm{$quote} = 67876)" . " and ({$quote}account{$quote}.{$quote}phonecstm{$quote} like '123456%')" . " and ({$quote}customfield1{$quote}.{$quote}value{$quote} = '2')" . " and ({$quote}account{$quote}.{$quote}textcstm{$quote} like 'Some Text%')" . " and ({$quote}account{$quote}.{$quote}textareacstm{$quote} like '%Some description%')" . " and ({$quote}account{$quote}.{$quote}urlcstm{$quote} like '%somesite.com%')" . "";
     $this->assertEquals($compareWhere, $where);
     $this->assertEquals(0, $joinTablesAdapter->getFromTableJoinCount());
     $this->assertEquals(2, $joinTablesAdapter->getLeftTableJoinCount());
     $leftTables = $joinTablesAdapter->getLeftTablesAndAliases();
     $this->assertEquals('customfield', $leftTables[0]['tableName']);
     $this->assertEquals('customfield', $leftTables[1]['tableName']);
     //Now test that the subsetSQL query produced is correct.
     $subsetSql = Account::makeSubsetOrCountSqlQuery('account', $joinTablesAdapter, 1, 5, $where, null);
     $compareSubsetSql = "select {$quote}account{$quote}.{$quote}id{$quote} id ";
     $compareSubsetSql .= "from {$quote}account{$quote} ";
     $compareSubsetSql .= "left join {$quote}customfield{$quote} on ";
     $compareSubsetSql .= "{$quote}customfield{$quote}.{$quote}id{$quote} = {$quote}account{$quote}.{$quote}dropdowncstm_customfield_id{$quote} ";
     $compareSubsetSql .= "left join {$quote}customfield{$quote} customfield1 on ";
     $compareSubsetSql .= "{$quote}customfield1{$quote}.{$quote}id{$quote} = {$quote}account{$quote}.{$quote}radiocstm_customfield_id{$quote} ";
     $compareSubsetSql .= "where " . $compareWhere . ' ';
     $compareSubsetSql .= 'limit 5 offset 1';
     $this->assertEquals($compareSubsetSql, $subsetSql);
     //Make sure the sql runs properly.
     $data = Account::getSubset($joinTablesAdapter, 0, 5, $where, null);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:40,代码来源:ModulesSearchWithDataProviderTest.php


注:本文中的Account::getSubset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。