Skip to content

Commit

Permalink
API CHANGE Rename SQLQuery prepareSelect to prepareWhere
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Harvey committed May 1, 2012
1 parent 2784891 commit c84254c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion model/Database.php
Expand Up @@ -732,7 +732,7 @@ public function sqlQueryToString(SQLQuery $sqlQuery) {
$text = "SELECT $distinct" . implode(", ", $sqlQuery->select);
}
if($sqlQuery->from) $text .= " FROM " . implode(" ", $sqlQuery->from);
if($sqlQuery->where) $text .= " WHERE (" . $sqlQuery->prepareSelect(). ")";
if($sqlQuery->where) $text .= " WHERE (" . $sqlQuery->prepareWhere(). ")";
if($sqlQuery->groupby) $text .= " GROUP BY " . $sqlQuery->prepareGroupBy();
if($sqlQuery->having) $text .= " HAVING ( " .$sqlQuery->prepareHaving() . " )";
if($sqlQuery->orderby) $text .= " ORDER BY " . $sqlQuery->prepareOrderBy();
Expand Down
20 changes: 8 additions & 12 deletions model/SQLQuery.php
Expand Up @@ -539,28 +539,26 @@ function replaceText($old, $new) {
}

public function getFilter() {
Deprecation::notice('3.0', 'Please use prepareSelect() instead of getFilter()');
return $this->prepareSelect();
Deprecation::notice('3.0', 'Please use prepareWhere() instead of getFilter()');
return $this->prepareWhere();
}

/**
* Return an SQL WHERE clause to filter a SELECT query.
*
* Returns the WHERE clauses ready for inserting into a query.
* @return string
*/
public function prepareSelect() {
public function prepareWhere() {
return ($this->where) ? implode(") {$this->connective} (" , $this->where) : '';
}

/**
* Returns the ORDER BY columns ready for inserting into a query
*
* Returns the ORDER BY clauses ready for inserting into a query.
* @return string
*/
public function prepareOrderBy() {
$statments = array();

if($order = $this->getOrderBy()) {
if($order = $this->getOrderBy()) {
foreach($order as $clause => $dir) {
$statements[] = trim($clause . ' '. $dir);
}
Expand All @@ -570,17 +568,15 @@ public function prepareOrderBy() {
}

/**
* Returns the GROUP by columns ready for inserting into a query.
*
* Returns the GROUP BY clauses ready for inserting into a query.
* @return string
*/
public function prepareGroupBy() {
return implode(", ", $this->groupby);
}

/**
* Returns the HAVING columns ready for inserting into a query.
*
* Returns the HAVING clauses ready for inserting into a query.
* @return string
*/
public function prepareHaving() {
Expand Down

0 comments on commit c84254c

Please sign in to comment.