From afb33c17751603c48941d505cd1727fc14cf0c6a Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Mar 2012 13:10:59 -0500 Subject: [PATCH] Fix bug with table prefix and columns. --- laravel/database/grammar.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/laravel/database/grammar.php b/laravel/database/grammar.php index 055b97a9..13d92d8e 100644 --- a/laravel/database/grammar.php +++ b/laravel/database/grammar.php @@ -89,9 +89,18 @@ public function wrap($value) // Since columns may be prefixed with their corresponding table // name so as to not make them ambiguous, we will need to wrap // the table and the column in keyword identifiers. - foreach (explode('.', $value) as $segment) + $segments = explode('.', $value); + + foreach ($segments as $key => $value) { - $wrapped[] = $this->wrap_value($segment); + if ($key == 0 and count($segments) > 1) + { + $wrapped[] = $this->wrap_table($value); + } + else + { + $wrapped[] = $this->wrap_value($value); + } } return implode('.', $wrapped);