laravel/laravel — Issue #321: Field name aliases not working with paginate() in v3
Author: paulboco
Created: 2012-02-08 16:35:35+00:00
State: open

I pulled changes in develop this moring and received the following error...

```
Unhandled Exception
Message:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' `first_name` AS `name_formatted`) FROM `tenants`' at line 1

Location:

/home/pbc/git/temp/laravel/database/connection.php on line 211

Stack Trace:

#0 /home/pbc/git/temp/laravel/database/connection.php(211): PDO->prepare('SELECT COUNT(*,...')
#1 /home/pbc/git/temp/laravel/database/connection.php(141): Laravel\Database\Connection->execute('SELECT COUNT(*,...', Array)
#2 /home/pbc/git/temp/laravel/database/connection.php(126): Laravel\Database\Connection->query('SELECT COUNT(*,...', Array)
#3 /home/pbc/git/temp/laravel/database/connection.php(104): Laravel\Database\Connection->first('SELECT COUNT(*,...', Array)
#4 /home/pbc/git/temp/laravel/database/query.php(638): Laravel\Database\Connection->only('SELECT COUNT(*,...', Array)
#5 /home/pbc/git/temp/laravel/database/query.php(823): Laravel\Database\Query->aggregate('COUNT', Array)
#6 [internal function]: Laravel\Database\Query->__call('count', Array)
#7 /home/pbc/git/temp/laravel/database/query.php(663): Laravel\Database\Query->count(Array)
#8 /home/pbc/git/temp/application/routes.php(45): Laravel\Database\Query->paginate(10, Array)
#9 [internal function]: {closure}()
#10 /home/pbc/git/temp/laravel/routing/route.php(135): call_user_func_array(Object(Closure), Array)
#11 /home/pbc/git/temp/laravel/routing/route.php(102): Laravel\Routing\Route->response()
#12 /home/pbc/git/temp/laravel/laravel.php(175): Laravel\Routing\Route->call()
#13 /home/pbc/git/temp/public/index.php(34): require('/home/pbc/git/t...')
#14 {main}
```
with this code...

```
$columns = array(
'*',
'first_name as name_alias',
);

$foo = DB::table('tenants')->paginate(10, $columns);
var_dump($foo);
```

This appears to be isolated to paginate() as the get() method produces the expected results.

A hard reset to tag v3.0.0-rc-1 does not produce the error.