本文整理汇总了PHP中DbCommand::leftJoin方法的典型用法代码示例。如果您正苦于以下问题:PHP DbCommand::leftJoin方法的具体用法?PHP DbCommand::leftJoin怎么用?PHP DbCommand::leftJoin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbCommand
的用法示例。
在下文中一共展示了DbCommand::leftJoin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: modifyElementsQuery
/**
* Modifies an element query
*
* @param DbCommand $query
* @param mixed $value
* @return null|false
*/
public function modifyElementsQuery(DbCommand $query, $value)
{
$handle = $this->model->handle;
$query->addSelect('count(follows.id) AS ' . craft()->content->fieldColumnPrefix . $handle);
$query->leftJoin('follows follows', 'follows.elementId = elements.id');
}
示例2: modifyElementsQuery
/**
* Modifies an element query targeting elements of this type.
*
* @param DbCommand $query
* @param ElementCriteriaModel $criteria
* @return mixed
*/
public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
{
$query->addSelect('forms.id,
forms.fieldLayoutId,
forms.groupId,
forms.name,
forms.handle,
forms.titleFormat,
forms.displaySectionTitles,
forms.redirectUri,
forms.submitAction,
forms.submitButtonText,
forms.notificationEnabled,
forms.notificationRecipients,
forms.notificationSubject,
forms.notificationSenderName,
forms.notificationSenderEmail,
forms.notificationReplyToEmail
')->join('sproutforms_forms forms', 'forms.id = elements.id');
if ($criteria->totalEntries) {
$query->addSelect('COUNT(entries.id) totalEntries');
$query->leftJoin('sproutforms_entries entries', 'entries.formId = forms.id');
}
if ($criteria->numberOfFields) {
$query->addSelect('COUNT(fields.id) numberOfFields');
$query->leftJoin('fieldlayoutfields fields', 'fields.layoutId = forms.fieldLayoutId');
}
if ($criteria->handle) {
$query->andWhere(DbHelper::parseParam('forms.handle', $criteria->handle, $query->params));
}
if ($criteria->groupId) {
$query->join('sproutforms_formgroups formgroups', 'formgroups.id = forms.groupId');
$query->andWhere(DbHelper::parseParam('forms.groupId', $criteria->groupId, $query->params));
}
}