Permalink
Browse files

added order and group to raw_select

  • Loading branch information...
1 parent cc63abf commit 4835973a9ee971817901b96b1521f028ab47829e @tthomas48 committed Mar 7, 2013
Showing with 5 additions and 4 deletions.
  1. +2 −2 BuyPlayTix/DataBean/DBAdapter.php
  2. +1 −1 BuyPlayTix/DataBean/IAdapter.php
  3. +2 −1 BuyPlayTix/DataBean/ObjectAdapter.php
@@ -230,7 +230,7 @@ function raw_update($table, $fields = array(), $where_fields = array()) {
}
- function raw_select($table, $fields = array(), $where_fields = array(), $cast_class = NULL) {
+ function raw_select($table, $fields = array(), $where_fields = array(), $cast_class = NULL, $order = array(), $group = array()) {
$db = DB::getInstance();
@@ -246,7 +246,7 @@ function raw_select($table, $fields = array(), $where_fields = array(), $cast_cl
$where_clause[] = $name . " $condition ? ";
$values[] = $value;
}
- $sql = "SELECT " . implode(",", $fields) . " FROM " . $table . " WHERE " . implode(" AND ", $where_clause);
+ $sql = "SELECT " . implode(",", $fields) . " FROM " . $table . " WHERE " . implode(" AND ", $where_clause) . (count($order) ? ' ORDER BY ' . implode(",", $order) : '') . (count($group) ? ' GROUP BY ' . implode(",", $group) : '');
$sth = $db->prepare($sql);
$result = $db->execute($sth, $values);
@@ -9,7 +9,7 @@ function delete($databean);
function raw_delete($table, $fields = array());
function raw_insert($table, $fields = array());
function raw_update($table, $fields = array(), $where_fields = array());
- function raw_select($table, $fields = array(), $cast_class = NULL);
+ function raw_select($table, $fields = array(), $cast_class = NULL, $order = array(), $group = array());
function named_query($name, $sql = "", $params = array(), $hash = true);
}
?>
@@ -224,7 +224,8 @@ function raw_insert($table, $fields = array()) {
}
$this->tables[$table][] = $fields;
}
- function raw_select($table, $fields = array(), $where_fields = array(), $cast_class = NULL) {
+ // TODO: Add order and grouping
+ function raw_select($table, $fields = array(), $where_fields = array(), $cast_class = NULL, $order = array(), $group = array()) {
if(!isset($this->tables[$table])) {
$this->tables[$table] = array();
}

0 comments on commit 4835973

Please sign in to comment.