mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR Fixing deprecated use of SQLQuery
This commit is contained in:
parent
23c93b9a44
commit
46f51d5653
@ -78,8 +78,8 @@ class Aggregate extends ViewableData {
|
||||
protected function query($attr) {
|
||||
$singleton = singleton($this->type);
|
||||
$query = $singleton->buildSQL($this->filter);
|
||||
$query->select($attr);
|
||||
$query->orderby = null;
|
||||
$query->setSelect($attr);
|
||||
$query->setOrderBy(array());
|
||||
$singleton->extend('augmentSQL', $query);
|
||||
return $query;
|
||||
}
|
||||
@ -161,8 +161,8 @@ class Aggregate_Relationship extends Aggregate {
|
||||
$query = $this->object->getManyManyComponentsQuery($this->relationship, $this->filter);
|
||||
}
|
||||
|
||||
$query->select($attr);
|
||||
$query->groupby = array();
|
||||
$query->setSelect($attr);
|
||||
$query->setGroupBy(array());
|
||||
|
||||
$singleton = singleton($this->type);
|
||||
$singleton->extend('augmentSQL', $query);
|
||||
|
@ -142,10 +142,10 @@ class SQLQuery {
|
||||
*
|
||||
* <code>
|
||||
* // pass fields to select as single parameter array
|
||||
* $query->select(array("Col1","Col2"))->from("MyTable");
|
||||
* $query->setSelect(array("Col1","Col2"))->setFrom("MyTable");
|
||||
*
|
||||
* // pass fields to select as multiple parameters
|
||||
* $query->select("Col1", "Col2")->from("MyTable");
|
||||
* $query->setSelect("Col1", "Col2")->setFrom("MyTable");
|
||||
* </code>
|
||||
*
|
||||
* @param string|array $fields
|
||||
@ -167,10 +167,10 @@ class SQLQuery {
|
||||
*
|
||||
* <code>
|
||||
* // pass fields to select as single parameter array
|
||||
* $query->select(array("Col1","Col2"))->from("MyTable");
|
||||
* $query->addSelect(array("Col1","Col2"))->setFrom("MyTable");
|
||||
*
|
||||
* // pass fields to select as multiple parameters
|
||||
* $query->select("Col1", "Col2")->from("MyTable");
|
||||
* $query->addSelect("Col1", "Col2")->setFrom("MyTable");
|
||||
* </code>
|
||||
*
|
||||
* @param string|array $fields
|
||||
@ -229,7 +229,7 @@ class SQLQuery {
|
||||
* Set table for the SELECT clause.
|
||||
*
|
||||
* <code>
|
||||
* $query->from("MyTable"); // SELECT * FROM MyTable
|
||||
* $query->setFrom("MyTable"); // SELECT * FROM MyTable
|
||||
* </code>
|
||||
*
|
||||
* @param string|array $from
|
||||
@ -244,7 +244,7 @@ class SQLQuery {
|
||||
* Add a table to the SELECT clause.
|
||||
*
|
||||
* <code>
|
||||
* $query->from("MyTable"); // SELECT * FROM MyTable
|
||||
* $query->addFrom("MyTable"); // SELECT * FROM MyTable
|
||||
* </code>
|
||||
*
|
||||
* @param string|array $from
|
||||
@ -937,13 +937,13 @@ class SQLQuery {
|
||||
return $countQuery->execute()->value();
|
||||
|
||||
} else {
|
||||
$clone->select = array("count(*)");
|
||||
$clone->setSelect(array("count(*)"));
|
||||
}
|
||||
} else {
|
||||
$clone->select = array("count($column)");
|
||||
$clone->setSelect(array("count($column)"));
|
||||
}
|
||||
|
||||
$clone->groupby = null;
|
||||
$clone->setGroupBy(array());;
|
||||
return $clone->execute()->value();
|
||||
}
|
||||
|
||||
@ -993,23 +993,23 @@ class SQLQuery {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a new SQLQuery that calls the given aggregate functions on this data.
|
||||
* @param $column An aggregate expression, such as 'MAX("Balance")', or a set of them.
|
||||
*/
|
||||
function aggregate($column) {
|
||||
/**
|
||||
* Return a new SQLQuery that calls the given aggregate functions on this data.
|
||||
* @param $column An aggregate expression, such as 'MAX("Balance")', or a set of them.
|
||||
*/
|
||||
function aggregate($column) {
|
||||
if($this->groupby || $this->limit) {
|
||||
throw new Exception("SQLQuery::aggregate() doesn't work with groupby or limit, yet");
|
||||
}
|
||||
throw new Exception("SQLQuery::aggregate() doesn't work with groupby or limit, yet");
|
||||
}
|
||||
|
||||
$clone = clone $this;
|
||||
$clone->limit = null;
|
||||
$clone->orderby = null;
|
||||
$clone->groupby = null;
|
||||
$clone->select($column);
|
||||
$clone->setLimit(array());
|
||||
$clone->setOrderBy(array());
|
||||
$clone->setGroupBy(array());
|
||||
$clone->setSelect($column);
|
||||
|
||||
return $clone;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a query that returns only the first row of this query
|
||||
|
@ -154,15 +154,15 @@ class Versioned extends DataExtension {
|
||||
$query->selectField(sprintf('"%s_versions"."%s"', $baseTable, 'RecordID'), "ID");
|
||||
|
||||
if($table != $baseTable) {
|
||||
$query->from(array($table => " AND \"{$table}_versions\".\"Version\" = \"{$baseTable}_versions\".\"Version\""));
|
||||
$query->addFrom(array($table => " AND \"{$table}_versions\".\"Version\" = \"{$baseTable}_versions\".\"Version\""));
|
||||
}
|
||||
}
|
||||
|
||||
// Link to the version archived on that date
|
||||
$archiveTable = $this->requireArchiveTempTable($baseTable, $date);
|
||||
$query->from[$archiveTable] = "INNER JOIN \"$archiveTable\"
|
||||
$query->addFrom(array($archiveTable => "INNER JOIN \"$archiveTable\"
|
||||
ON \"$archiveTable\".\"ID\" = \"{$baseTable}_versions\".\"RecordID\"
|
||||
AND \"$archiveTable\".\"Version\" = \"{$baseTable}_versions\".\"Version\"";
|
||||
AND \"$archiveTable\".\"Version\" = \"{$baseTable}_versions\".\"Version\""));
|
||||
break;
|
||||
|
||||
// Reading a specific stage (Stage or Live)
|
||||
|
@ -37,8 +37,8 @@
|
||||
*
|
||||
* function addToQuery(&$query) {
|
||||
* parent::addToQuery($query);
|
||||
* $query->select("{$this->name}Number");
|
||||
* $query->select("{$this->name}Name");
|
||||
* $query->setSelect("{$this->name}Number");
|
||||
* $query->setSelect("{$this->name}Name");
|
||||
* }
|
||||
*
|
||||
* function setValue($value, $record = null, $markChanged=true) {
|
||||
|
Loading…
Reference in New Issue
Block a user