本文整理匯總了PHP中DataQuery::execute方法的典型用法代碼示例。如果您正苦於以下問題:PHP DataQuery::execute方法的具體用法?PHP DataQuery::execute怎麽用?PHP DataQuery::execute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DataQuery
的用法示例。
在下文中一共展示了DataQuery::execute方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getUnusedFilesListFilter
/**
* Looks for files used in system and create where clause which contains all ID's of files.
*
* @returns String where clause which will work as filter.
*/
public function getUnusedFilesListFilter()
{
$result = DB::query("SELECT DISTINCT \"FileID\" FROM \"SiteTree_ImageTracking\"");
$usedFiles = array();
$where = '';
$classes = ClassInfo::subclassesFor('SiteTree');
if ($result->numRecords() > 0) {
while ($nextResult = $result->next()) {
$where .= $nextResult['FileID'] . ',';
}
}
foreach ($classes as $className) {
$query = new DataQuery($className);
$ids = $query->execute()->column();
if (!count($ids)) {
continue;
}
foreach (singleton($className)->hasOne() as $relName => $joinClass) {
if ($joinClass == 'Image' || $joinClass == 'File') {
$fieldName = $relName . 'ID';
$query = DataList::create($className)->where("{$fieldName} > 0");
$query->distinct = true;
$query->select(array($fieldName));
$usedFiles = array_merge($usedFiles, $query->execute()->column());
} elseif ($joinClass == 'Folder') {
// @todo
}
}
}
if ($usedFiles) {
return "\"File\".\"ID\" NOT IN (" . implode(', ', $usedFiles) . ") AND (\"ClassName\" = 'File' OR \"ClassName\" = 'Image')";
} else {
return "(\"ClassName\" = 'File' OR \"ClassName\" = 'Image')";
}
return $where;
// @todo - How?
}
示例2: testRelationOrderWithCustomJoin
public function testRelationOrderWithCustomJoin()
{
$dataQuery = new DataQuery('DataQueryTest_B');
$dataQuery->innerJoin('DataQueryTest_D', '"DataQueryTest_D"."RelationID" = "DataQueryTest_B"."ID"');
$dataQuery->execute();
}