本文整理匯總了PHP中DbCommand::getText方法的典型用法代碼示例。如果您正苦於以下問題:PHP DbCommand::getText方法的具體用法?PHP DbCommand::getText怎麽用?PHP DbCommand::getText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DbCommand
的用法示例。
在下文中一共展示了DbCommand::getText方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _getElementsFromQuery
/**
* Returns elements based on a given query.
*
* @access private
* @param BaseElementType $elementType
* @param DbCommand $subquery
* @param bool $ordered
* @return array
*/
private function _getElementsFromQuery(BaseElementType $elementType, DbCommand $subquery, $ordered = false)
{
if ($ordered) {
$subquery->addSelect('relations.sortOrder');
}
// Only get the unique elements (no locale duplicates)
$query = craft()->db->createCommand()->select('*')->from('(' . $subquery->getText() . ') AS ' . craft()->db->quoteTableName('r'))->group('r.id');
$query->params = $subquery->params;
if ($ordered) {
$query->order('sortOrder');
}
$result = $query->queryAll();
$elements = array();
foreach ($result as $row) {
// The locale column might be null since the element_i18n table was left-joined into the query,
// In that case it should be removed from the $row array so that the default value can be used.
if (!$row['locale']) {
unset($row['locale']);
}
$elements[] = $elementType->populateElementModel($row);
}
return $elements;
}