improved performance. added support for database ports.
This commit is contained in:
@@ -51,8 +51,21 @@ class Connector {
|
||||
// -----------------------------------------------------
|
||||
elseif ($config->driver == 'mysql' or $config->driver == 'pgsql')
|
||||
{
|
||||
$connection = new \PDO($config->driver.':host='.$config->host.';dbname='.$config->database, $config->username, $config->password, static::$options);
|
||||
// -----------------------------------------------------
|
||||
// Build the PDO connection DSN.
|
||||
// -----------------------------------------------------
|
||||
$dsn = $config->driver.':host='.$config->host.';dbname='.$config->database;
|
||||
|
||||
if (isset($config->port))
|
||||
{
|
||||
$dsn .= ';port='.$config->port;
|
||||
}
|
||||
|
||||
$connection = new \PDO($dsn, $config->username, $config->password, static::$options);
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Set the appropriate character set for the datbase.
|
||||
// -----------------------------------------------------
|
||||
if (isset($config->charset))
|
||||
{
|
||||
$connection->prepare("SET NAMES '".$config->charset."'")->execute();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php namespace System\DB;
|
||||
|
||||
use System\Str;
|
||||
use System\Config;
|
||||
use System\Inflector;
|
||||
|
||||
abstract class Eloquent {
|
||||
@@ -102,7 +103,7 @@ abstract class Eloquent {
|
||||
return $class::$table;
|
||||
}
|
||||
|
||||
return Str::lower(Inflector::plural($class));
|
||||
return strtolower(Inflector::plural($class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,7 +214,7 @@ abstract class Eloquent {
|
||||
// For example, the foreign key for a User model would
|
||||
// be user_id. Photo would be photo_id, etc.
|
||||
// -----------------------------------------------------
|
||||
$this->relating_key = (is_null($foreign_key)) ? Str::lower(get_class($this)).'_id' : $foreign_key;
|
||||
$this->relating_key = (is_null($foreign_key)) ? strtolower(get_class($this)).'_id' : $foreign_key;
|
||||
|
||||
return static::make($model)->where($this->relating_key, '=', $this->id);
|
||||
}
|
||||
@@ -276,7 +277,7 @@ abstract class Eloquent {
|
||||
|
||||
sort($models);
|
||||
|
||||
$this->relating_table = Str::lower($models[0].'_'.$models[1]);
|
||||
$this->relating_table = strtolower($models[0].'_'.$models[1]);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
@@ -286,11 +287,11 @@ abstract class Eloquent {
|
||||
//
|
||||
// This is the same convention as has_one and has_many.
|
||||
// -----------------------------------------------------
|
||||
$this->relating_key = Str::lower(get_class($this)).'_id';
|
||||
$this->relating_key = strtolower(get_class($this)).'_id';
|
||||
|
||||
return static::make($model)
|
||||
->select(static::table($model).'.*')
|
||||
->join($this->relating_table, static::table($model).'.id', '=', $this->relating_table.'.'.Str::lower($model).'_id')
|
||||
->join($this->relating_table, static::table($model).'.id', '=', $this->relating_table.'.'.strtolower($model).'_id')
|
||||
->where($this->relating_table.'.'.$this->relating_key, '=', $this->id);
|
||||
}
|
||||
|
||||
|
||||
@@ -326,7 +326,7 @@ class Query {
|
||||
*/
|
||||
public function order_by($column, $direction)
|
||||
{
|
||||
$this->orderings[] = $this->wrap($column).' '.Str::upper($direction);
|
||||
$this->orderings[] = $this->wrap($column).' '.strtoupper($direction);
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -516,7 +516,7 @@ class Query {
|
||||
// ---------------------------------------------------------
|
||||
if (in_array($method, array('count', 'min', 'max', 'avg', 'sum')))
|
||||
{
|
||||
return ($method == 'count') ? $this->aggregate(Str::upper($method), '*') : $this->aggregate(Str::upper($method), $parameters[0]);
|
||||
return ($method == 'count') ? $this->aggregate(strtoupper($method), '*') : $this->aggregate(strtoupper($method), $parameters[0]);
|
||||
}
|
||||
|
||||
throw new \Exception("Method [$method] is not defined on the Query class.");
|
||||
|
||||
@@ -55,7 +55,7 @@ class Dynamic {
|
||||
}
|
||||
else
|
||||
{
|
||||
$connector = trim(Str::upper($segment), '_');
|
||||
$connector = trim(strtoupper($segment), '_');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user