Useful PHP database class

前端 未结 11 1217
生来不讨喜
生来不讨喜 2021-02-06 06:21

I am working on a small PHP website. I need a MySql database access class that is easy to configure and work with.

Does not need to be a full framework, I only need a ma

11条回答
  •  逝去的感伤
    2021-02-06 07:03

    ADODb is pretty easy to work with and worth considering. Some illustrative samples:

      //connect
      $dsn = 'mysql://user:pwd@localhost/mydb'; 
      $db = ADONewConnection($dsn);  
    
      //get a single value     
      $value=$db->GetOne("select foo from bar where x=?", array($x));
    
      //get a row
      $row=$db->GetRow("select * from bar where x=?", array($x));
    
      //easy insert example
      $record=array("id"=>1, "foo"=>"bar");
      $db->AutoExecute("table", $record, "INSERT");  
    

提交回复
热议问题