Database abstraction class design using PHP PDO

前端 未结 4 1798
梦毁少年i
梦毁少年i 2021-01-03 05:44

I am in the process of designing a web application (really, it\'s a hobby, and I\'m trying to teach myself design, and what better way is there than doing it :). Anyway, I

4条回答
  •  情话喂你
    2021-01-03 05:51

    Yeah, this is a good start. PDO + singleton is an often-used and great combination. As I personally don't like all the typing involved than using singletons, I have written a very lightweight database class.

    It introduces only two additional features over PDO: Access of (lazy) PDO instance using __callStatic (DB::query() instead of DB::instance()->query()) and two functions for easier quoting (DB::q('INSERT INTO table (name) VALUES (?s)', $_POST['insecure_name'])). Maybe you want to look at both, it's really handy ;)

提交回复
热议问题