MINOR: Remove uses of deprecated extendedSQL()

This commit is contained in:
Sam Minnee 2011-10-29 17:12:37 +13:00
parent 5ed14915bb
commit a5a94b520f
3 changed files with 19 additions and 19 deletions

View File

@ -834,11 +834,12 @@ class MySQLDatabase extends SS_Database {
$match['SiteTree'] = $match['File'] = "1 = 1"; $match['SiteTree'] = $match['File'] = "1 = 1";
} }
// Generate initial queries and base table names // Generate initial DataLists and base table names
$lists = array();
$baseClasses = array('SiteTree' => '', 'File' => ''); $baseClasses = array('SiteTree' => '', 'File' => '');
foreach($classesToSearch as $class) { foreach($classesToSearch as $class) {
$queries[$class] = singleton($class)->extendedSQL($notMatch . $match[$class] . $extraFilters[$class], ""); $lists[$class] = DataList::create($class)->where($notMatch . $match[$class] . $extraFilters[$class], "");
$baseClasses[$class] = reset($queries[$class]->from); $baseClasses[$class] = '"'.$class.'"';
} }
// Make column selection lists // Make column selection lists
@ -847,18 +848,17 @@ class MySQLDatabase extends SS_Database {
'File' => array("ClassName","$baseClasses[File].ID","_utf8'' AS ParentID","Title","_utf8'' AS MenuTitle","_utf8'' AS URLSegment","Content","LastEdited","Created","Filename","Name","$relevance[File] AS Relevance","NULL AS CanViewType"), 'File' => array("ClassName","$baseClasses[File].ID","_utf8'' AS ParentID","Title","_utf8'' AS MenuTitle","_utf8'' AS URLSegment","Content","LastEdited","Created","Filename","Name","$relevance[File] AS Relevance","NULL AS CanViewType"),
); );
// Process queries // Process and combine queries
foreach($classesToSearch as $class) {
// There's no need to do all that joining
$queries[$class]->from = array(str_replace('`','',$baseClasses[$class]) => $baseClasses[$class]);
$queries[$class]->select = $select[$class];
$queries[$class]->orderby = null;
}
// Combine queries
$querySQLs = array(); $querySQLs = array();
$totalCount = 0; $totalCount = 0;
foreach($queries as $query) { foreach($lists as $class => $list) {
$query = $list->dataQuery()->query();
// There's no need to do all that joining
$query->from = array(str_replace(array('"','`'),'',$baseClasses[$class]) => $baseClasses[$class]);
$query->select = $select[$class];
$query->orderby = null;
$querySQLs[] = $query->sql(); $querySQLs[] = $query->sql();
$totalCount += $query->unlimitedRowCount(); $totalCount += $query->unlimitedRowCount();
} }

View File

@ -683,8 +683,11 @@ class Versioned extends DataExtension {
// Make sure the table names are not postfixed (e.g. _Live) // Make sure the table names are not postfixed (e.g. _Live)
$oldMode = self::get_reading_mode(); $oldMode = self::get_reading_mode();
self::reading_stage('Stage'); self::reading_stage('Stage');
$query = $this->owner->extendedSQL($filter, $sort, $limit, $join, $having); $list = DataObject::get(get_class($this->owner), $filter, $sort, $limit, $join);
if($having) $having = $list->having($having);
$query = $list->dataQuery()->query();
foreach($query->from as $table => $tableJoin) { foreach($query->from as $table => $tableJoin) {
if(is_string($tableJoin) && $tableJoin[0] == '"') { if(is_string($tableJoin) && $tableJoin[0] == '"') {

View File

@ -257,10 +257,7 @@ class Group extends DataObject {
// Get the children of *all* the groups identified in the previous chunk. // Get the children of *all* the groups identified in the previous chunk.
// This minimises the number of SQL queries necessary // This minimises the number of SQL queries necessary
$sql = $this->extendedSQL("\"ParentID\" IN ($idList)", ""); $chunkToAdd = DataList::create('Group')->where("\"ParentID\" IN ($idList)")->column('ID');
$dbResult = $sql->execute();
$chunkToAdd = array();
foreach($dbResult as $item) $chunkToAdd[] = $item;
} }
return $familyIDs; return $familyIDs;