Commit 3507d153 authored by Taylor Otwell's avatar Taylor Otwell

fix charset in mysql and pgsql connectors.

parent bf6313e5
...@@ -32,7 +32,7 @@ class MySQL extends Connector { ...@@ -32,7 +32,7 @@ class MySQL extends Connector {
if (isset($config['charset'])) if (isset($config['charset']))
{ {
$connection->prepare("SET NAMES '{$charset}'")->execute(); $connection->prepare("SET NAMES '{$config['charset']}'")->execute();
} }
return $connection; return $connection;
......
...@@ -32,7 +32,7 @@ class Postgres extends Connector { ...@@ -32,7 +32,7 @@ class Postgres extends Connector {
if (isset($config['charset'])) if (isset($config['charset']))
{ {
$connection->prepare("SET NAMES '{$charset}'")->execute(); $connection->prepare("SET NAMES '{$config['charset']}'")->execute();
} }
return $connection; return $connection;
......
...@@ -157,6 +157,7 @@ class Query { ...@@ -157,6 +157,7 @@ class Query {
call_user_func($column1, end($this->joins)); call_user_func($column1, end($this->joins));
} }
// If the column is just a string, we can assume that the join just // If the column is just a string, we can assume that the join just
// has a simple on clause, and we'll create the join instance and // has a simple on clause, and we'll create the join instance and
// add the clause automatically for the develoepr. // add the clause automatically for the develoepr.
...@@ -648,15 +649,18 @@ class Query { ...@@ -648,15 +649,18 @@ class Query {
*/ */
public function aggregate($aggregator, $columns) public function aggregate($aggregator, $columns)
{ {
// We'll set the aggregate value so the grammar does not try to compile
// a SELECT clause on the query. If an aggregator is present, it's own
// grammar function will be used to build the SQL syntax.
$this->aggregate = compact('aggregator', 'columns'); $this->aggregate = compact('aggregator', 'columns');
$sql = $this->grammar->select($this); $sql = $this->grammar->select($this);
$result = $this->connection->only($sql, $this->bindings); $result = $this->connection->only($sql, $this->bindings);
// Reset the aggregate so more queries can be performed using // Reset the aggregate so more queries can be performed using the same
// the same instance. This is helpful for getting aggregates // instance. This is helpful for getting aggregates and then getting
// and then getting actual results from the query. // actual results from the query such as during paging.
$this->aggregate = null; $this->aggregate = null;
return $result; return $result;
...@@ -673,8 +677,7 @@ class Query { ...@@ -673,8 +677,7 @@ class Query {
{ {
// Because some database engines may throw errors if we leave orderings // Because some database engines may throw errors if we leave orderings
// on the query when retrieving the total number of records, we'll drop // on the query when retrieving the total number of records, we'll drop
// all of the ordreings and put them back on the query after we have // all of the ordreings and put them back on the query.
// retrieved the count from the table.
list($orderings, $this->orderings) = array($this->orderings, null); list($orderings, $this->orderings) = array($this->orderings, null);
$total = $this->count(reset($columns)); $total = $this->count(reset($columns));
...@@ -685,8 +688,7 @@ class Query { ...@@ -685,8 +688,7 @@ class Query {
// Now we're ready to get the actual pagination results from the table // Now we're ready to get the actual pagination results from the table
// using the for_page and get methods. The "for_page" method provides // using the for_page and get methods. The "for_page" method provides
// a convenient way to set the limit and offset so we get the correct // a convenient way to set the paging limit and offset.
// span of results from the table.
$results = $this->for_page($page, $per_page)->get($columns); $results = $this->for_page($page, $per_page)->get($columns);
return Paginator::make($results, $total, $per_page); return Paginator::make($results, $total, $per_page);
...@@ -773,10 +775,12 @@ class Query { ...@@ -773,10 +775,12 @@ class Query {
*/ */
protected function adjust($column, $amount, $operator) protected function adjust($column, $amount, $operator)
{ {
// To make the adjustment to the column, we'll wrap the expression $wrapped = $this->grammar->wrap($column);
// in an Expression instance, which forces the adjustment to be
// injected into the query as a string instead of bound. // To make the adjustment to the column, we'll wrap the expression in
$value = Database::raw($this->grammar->wrap($column).$operator.$amount); // an Expression instance, which forces the adjustment to be injected
// into the query as a string instead of bound.
$value = Database::raw($wrapped.$operator.$amount);
return $this->update(array($column => $value)); return $this->update(array($column => $value));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment