PDO4You 3.0 發布,增加MariaDB數據庫支持
PDO4You這個類是基于PDO,這是一個PHP擴展,允許開發人員創建可移植的代碼,從而滿足最流行的數據庫。包括:MySQL, PostgreSQL, Oracle, MS SQL Server, Sybase。
- 抽象的連接
- 防止SQL注入
- 預定義的CRUD方法
- 多數據庫連接
- SQL compact using JSON notation
- Handling errors with Stack Trace
查詢數據庫中的記錄 <?php // Starting a connection instance. The default connection is not persistent PDO4You::getInstance(); // Defining a persistent communication with the database PDO4You::setPersistent(true); // Selecting records in the database PDO4You::select('SELECT * FROM books LIMIT 2'); // Selecting records and setting that connection instance will be used PDO4You::select('SELECT * FROM books LIMIT 2', 'instance_name'); // Query statement $sql = 'SELECT * FROM books LIMIT 2'; // Selecting records with FETCH_ASSOC $result = PDO4You::select($sql); // Selecting records with FETCH_NUM $result = PDO4You::selectNum($sql); // Selecting records with FETCH_OBJ $result = PDO4You::selectObj($sql); // Selecting records with FETCH_BOTH $result = PDO4You::selectAll($sql); // Selecting all records $result = PDO4You::select('SELECT * FROM books'); // Getting the total number of rows affected by the operation $total = PDO4You::rowCount(); // Displaying the query results echo '<pre><h3>Query Result:</h3> ' , print_r($result, true) , '</pre>'; ?>
這次發布主要是支持MariaDB數據庫。
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!