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