Re:The Last PHP PDO Library You Will Ever Need
by hippich on Friday November 04, 2011 @08:32AM
(#3195777)
It is so simple:
- If you do quick ad hoc script/page - use straight sql with mysql_query
- If you extend it - use something like PDO
- If you build real application, you have to use Model layer. And no matter what you prefer at this point - you'd better to put everything behind Model be it PDO-based queries, some dynamic objectish query builders or full-scale ORM like DBIx::Class (sorry, this is for Perl, not very familiar with something like this in PHP. If someone know good analogs in PHP - please post links to these).
Right tool for right task - this is what important to keep in mind.
PS: Sorry, but seeing straight SQL in what looks like an action, is really hurt my eyes. If you opted for MVC framework, you'd probably want to push all SQL into model and leave meaningful calls to it.
- If you do quick ad hoc script/page - use straight sql with mysql_query
- If you extend it - use something like PDO
- If you build real application, you have to use Model layer. And no matter what you prefer at this point - you'd better to put everything behind Model be it PDO-based queries, some dynamic objectish query builders or full-scale ORM like DBIx::Class (sorry, this is for Perl, not very familiar with something like this in PHP. If someone know good analogs in PHP - please post links to these).
Right tool for right task - this is what important to keep in mind.
PS: Sorry, but seeing straight SQL in what looks like an action, is really hurt my eyes. If you opted for MVC framework, you'd probably want to push all SQL into model and leave meaningful calls to it.