From b4c7dcb9ea94a7732bb1d635246cee3168926967 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 19 Jul 2011 11:17:51 -0700 Subject: [PATCH] Added support for 'wrap' option. --- system/db/query.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/system/db/query.php b/system/db/query.php index cc1e5bb2..68aaae4e 100644 --- a/system/db/query.php +++ b/system/db/query.php @@ -13,6 +13,13 @@ class Query { */ private $connection; + /** + * The database connection configuration. + * + * @var array + */ + private $config; + /** * The SELECT clause. * @@ -512,6 +519,18 @@ class Query { */ 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') ? '`' : '"'; return implode('.', array_map(function($segment) use ($wrap) {return ($segment != '*') ? $wrap.$segment.$wrap : $segment;}, explode('.', $value)));