fix charset in mysql and pgsql connectors.
This commit is contained in:
@@ -32,7 +32,7 @@ class MySQL extends Connector {
|
||||
|
||||
if (isset($config['charset']))
|
||||
{
|
||||
$connection->prepare("SET NAMES '{$charset}'")->execute();
|
||||
$connection->prepare("SET NAMES '{$config['charset']}'")->execute();
|
||||
}
|
||||
|
||||
return $connection;
|
||||
|
||||
@@ -32,7 +32,7 @@ class Postgres extends Connector {
|
||||
|
||||
if (isset($config['charset']))
|
||||
{
|
||||
$connection->prepare("SET NAMES '{$charset}'")->execute();
|
||||
$connection->prepare("SET NAMES '{$config['charset']}'")->execute();
|
||||
}
|
||||
|
||||
return $connection;
|
||||
|
||||
@@ -157,6 +157,7 @@ class Query {
|
||||
|
||||
call_user_func($column1, end($this->joins));
|
||||
}
|
||||
|
||||
// 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
|
||||
// add the clause automatically for the develoepr.
|
||||
@@ -648,15 +649,18 @@ class Query {
|
||||
*/
|
||||
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');
|
||||
|
||||
$sql = $this->grammar->select($this);
|
||||
|
||||
$result = $this->connection->only($sql, $this->bindings);
|
||||
|
||||
// Reset the aggregate so more queries can be performed using
|
||||
// the same instance. This is helpful for getting aggregates
|
||||
// and then getting actual results from the query.
|
||||
// Reset the aggregate so more queries can be performed using the same
|
||||
// instance. This is helpful for getting aggregates and then getting
|
||||
// actual results from the query such as during paging.
|
||||
$this->aggregate = null;
|
||||
|
||||
return $result;
|
||||
@@ -673,8 +677,7 @@ class Query {
|
||||
{
|
||||
// Because some database engines may throw errors if we leave orderings
|
||||
// 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
|
||||
// retrieved the count from the table.
|
||||
// all of the ordreings and put them back on the query.
|
||||
list($orderings, $this->orderings) = array($this->orderings, null);
|
||||
|
||||
$total = $this->count(reset($columns));
|
||||
@@ -685,8 +688,7 @@ class Query {
|
||||
|
||||
// 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
|
||||
// a convenient way to set the limit and offset so we get the correct
|
||||
// span of results from the table.
|
||||
// a convenient way to set the paging limit and offset.
|
||||
$results = $this->for_page($page, $per_page)->get($columns);
|
||||
|
||||
return Paginator::make($results, $total, $per_page);
|
||||
@@ -773,10 +775,12 @@ class Query {
|
||||
*/
|
||||
protected function adjust($column, $amount, $operator)
|
||||
{
|
||||
// To make the adjustment to the column, we'll wrap the expression
|
||||
// in an Expression instance, which forces the adjustment to be
|
||||
// injected into the query as a string instead of bound.
|
||||
$value = Database::raw($this->grammar->wrap($column).$operator.$amount);
|
||||
$wrapped = $this->grammar->wrap($column);
|
||||
|
||||
// To make the adjustment to the column, we'll wrap the expression in
|
||||
// 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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user