当前位置: 首页>>代码示例>>PHP>>正文


PHP DataQuery::execute方法代码示例

本文整理汇总了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?
 }
开发者ID:helpfulrobot,项目名称:comperio-silverstripe-cms,代码行数:42,代码来源:SiteTreeFolderExtension.php

示例2: testRelationOrderWithCustomJoin

 public function testRelationOrderWithCustomJoin()
 {
     $dataQuery = new DataQuery('DataQueryTest_B');
     $dataQuery->innerJoin('DataQueryTest_D', '"DataQueryTest_D"."RelationID" = "DataQueryTest_B"."ID"');
     $dataQuery->execute();
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:6,代码来源:DataQueryTest.php


注:本文中的DataQuery::execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。