本文整理匯總了PHP中EmailMessage::makeSubsetOrCountSqlQuery方法的典型用法代碼示例。如果您正苦於以下問題:PHP EmailMessage::makeSubsetOrCountSqlQuery方法的具體用法?PHP EmailMessage::makeSubsetOrCountSqlQuery怎麽用?PHP EmailMessage::makeSubsetOrCountSqlQuery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類EmailMessage
的用法示例。
在下文中一共展示了EmailMessage::makeSubsetOrCountSqlQuery方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testResolveSearchAttributesDataByRelatedItemIdWithRegularUser
public function testResolveSearchAttributesDataByRelatedItemIdWithRegularUser()
{
Yii::app()->user->userModel = User::getByUsername('benny');
$mungeIds = ReadPermissionsOptimizationUtil::getMungeIdsByUser(Yii::app()->user->userModel);
$quote = DatabaseCompatibilityUtil::getQuote();
$rules = new EmailMessageMashableActivityRules();
$searchAttributeData = $rules->resolveSearchAttributesDataByRelatedItemId(5);
$joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('EmailMessage');
$where = RedBeanModelDataProvider::makeWhere('EmailMessage', $searchAttributeData, $joinTablesAdapter);
$compareWhere = "(({$quote}emailmessagesender{$quote}.{$quote}personoraccount_item_id{$quote} = 5) or (1 = ";
$compareWhere .= "(select 1 from {$quote}emailmessagerecipient{$quote} emailmessagerecipient where ";
$compareWhere .= "{$quote}emailmessagerecipient{$quote}.{$quote}emailmessage_id` = {$quote}emailmessage";
$compareWhere .= "{$quote}.id and {$quote}emailmessagerecipient{$quote}.{$quote}personoraccount_item_id` = 5 limit 1)))";
$this->assertEquals($compareWhere, $where);
$sql = EmailMessage::makeSubsetOrCountSqlQuery('emailmessage', $joinTablesAdapter, 1, 5, $where, null);
$compareSubsetSql = "select distinct {$quote}emailmessage{$quote}.{$quote}id{$quote} id ";
$compareSubsetSql .= "from ({$quote}emailmessage{$quote}, {$quote}ownedsecurableitem{$quote}) ";
$compareSubsetSql .= "left join {$quote}emailmessagesender{$quote} on ";
$compareSubsetSql .= "{$quote}emailmessagesender{$quote}.{$quote}id{$quote} = {$quote}emailmessage{$quote}.";
$compareSubsetSql .= "{$quote}sender_emailmessagesender_id{$quote} ";
$compareSubsetSql .= "left join {$quote}emailmessage_read{$quote} on ";
$compareSubsetSql .= "{$quote}emailmessage_read{$quote}.{$quote}securableitem_id{$quote} = ";
$compareSubsetSql .= "{$quote}ownedsecurableitem{$quote}.{$quote}securableitem_id{$quote} ";
$compareSubsetSql .= "and {$quote}munge_id{$quote} in ('" . join("', '", $mungeIds) . "') ";
$compareSubsetSql .= "where (" . $compareWhere . ') ';
$compareSubsetSql .= "and ({$quote}ownedsecurableitem{$quote}.{$quote}owner__user_id{$quote} = " . Yii::app()->user->userModel->id . " ";
// Not Coding Standard
$compareSubsetSql .= "OR {$quote}emailmessage_read{$quote}.{$quote}munge_id{$quote} IS NOT NULL) ";
// Not Coding Standard
$compareSubsetSql .= "and {$quote}ownedsecurableitem{$quote}.{$quote}id{$quote} = ";
$compareSubsetSql .= "{$quote}emailmessage{$quote}.{$quote}ownedsecurableitem_id{$quote} ";
$compareSubsetSql .= 'limit 5 offset 1';
$this->assertEquals($compareSubsetSql, $sql);
//Make sure the sql runs properly.
$data = EmailMessage::getSubset($joinTablesAdapter, 0, 5, $where, null);
$this->assertEquals(0, count($data));
}