Is there a better, more “Standard” way to perform SQL queries in PHP without using a framework?

前端 未结 8 1078
借酒劲吻你
借酒劲吻你 2021-01-27 09:02

For the longest time, I\'ve been using the following basic formatting for SQL queries within my PHP:

$sql = \"SELECT * FROM `user-data` WHERE `id` = \'\".$id.\"\         


        
8条回答
  •  我在风中等你
    2021-01-27 09:18

    Another vote for doctrine. Don't waste your time with PDO. I can't emphasize this enough. Go with an orm. Forget about wasting time writing CRUD methods, custom caching logic, and worrying about premature optimization such as "overhead" resulting from a library. The overhead incurred by spattering statements like "select * from app_users" and their associated ugly heredocs isn't worth it.

    If you need to fall back to sql, you can. The other 90% of the time you're in a state of bliss.

    http://www.doctrine-project.org/

提交回复
热议问题