lox / pheasant

A lightweight data mapper designed to take advantage of PHP 5.3+
http://getpheasant.com
MIT License
101 stars 21 forks source link

Improve Model::all()->first() #158

Open Jud opened 8 years ago

Jud commented 8 years ago

I had User::all()->first() in some test code, and I was a bit surprised when it ran out of memory when run against the staging database. Looks like the generated sql is something like SELECT User.* FROM users as User, which creates an object for each row before selecting the first one.

Would anyone have an issue with a PR to make ::all()->first() work identical to ::all()->orderBy('primaryKey asc')->limit(1)?

Same applies to ::all()->last().