Added support for 'wrap' option.
This commit is contained in:
@@ -13,6 +13,13 @@ class Query {
|
|||||||
*/
|
*/
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The database connection configuration.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The SELECT clause.
|
* The SELECT clause.
|
||||||
*
|
*
|
||||||
@@ -512,6 +519,18 @@ class Query {
|
|||||||
*/
|
*/
|
||||||
public function wrap($value)
|
public function wrap($value)
|
||||||
{
|
{
|
||||||
|
if (is_null($this->config))
|
||||||
|
{
|
||||||
|
$connections = Config::get('db.connections');
|
||||||
|
|
||||||
|
$this->config = $connections[$this->connection];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('wrap', $this->config) and $this->config['wrap'] === false)
|
||||||
|
{
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
$wrap = (DB::driver($this->connection) == 'mysql') ? '`' : '"';
|
$wrap = (DB::driver($this->connection) == 'mysql') ? '`' : '"';
|
||||||
|
|
||||||
return implode('.', array_map(function($segment) use ($wrap) {return ($segment != '*') ? $wrap.$segment.$wrap : $segment;}, explode('.', $value)));
|
return implode('.', array_map(function($segment) use ($wrap) {return ($segment != '*') ? $wrap.$segment.$wrap : $segment;}, explode('.', $value)));
|
||||||
|
|||||||
Reference in New Issue
Block a user