Download the PHP package fulldecent/thin-pdo without Composer
On this page you can find all versions of the php package fulldecent/thin-pdo. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fulldecent/thin-pdo
More information about fulldecent/thin-pdo
Files in fulldecent/thin-pdo
Package thin-pdo
Short Description A minimal extension for PHP's PDO class designed to make running SQL statements easier
License MIT
Homepage http://github.com/fulldecent/pdo-wrapper
Informations about the package thin-pdo
DEPRECATION NOTICE: This code worked great for me on production systems for years. Going forward I use and recommend the approach described at https://phpdelusions.net/pdo as superior.
PHP PDO Wrapper Class
A minimal extension for PHP's PDO class designed to make running SQL statements easier.
Project Overview
This project provides a minimal extension for PHP's PDO (PHP Data Objects) class designed for ease-of-use and saving development time/effort. This is achived by providing methods - delete, insert, select, and update - for quickly building common SQL statements, handling exceptions when SQL errors are produced, and automatically returning results/number of affected rows for the appropriate SQL statement types.
System Requirements
-
PHP 5.5+ (any current PHP version, see https://secure.php.net/supported-versions.php)
-
PDO Extension
-
Appropriate PDO Driver(s) - PDO_SQLITE, PDO_MYSQL, PDO_PGSQL
- Only MySQL, SQLite, and PostgreSQL database types are currently supported.
db Class Methods
Below you will find a detailed explanation along with code samples for each of the 6 methods included in the db class.
constructor
More information can be found on how to set the dsn parameter by following the links provided below.
-
MySQL - http://us3.php.net/manual/en/ref.pdo-mysql.connection.php
-
SQLite - http://us3.php.net/manual/en/ref.pdo-sqlite.connection.php
- PostreSQL - http://us3.php.net/manual/en/ref.pdo-pgsql.connection.php
delete
If no SQL errors are produced, this method will return the number of rows affected by the DELETE statement.
insert
If no SQL errors are produced, this method will return the number of rows affected by the INSERT statement.
See also: $db->lastInsertId();
which is inherited from PDO.
run
This method is used to run free-form SQL statements that can't be handled by the included delete, insert, select, or update methods. If no SQL errors are produced, this method will return the number of affected rows for DELETE, INSERT, and UPDATE statements, or an associate array of results for SELECT, DESCRIBE, and PRAGMA statements.
select
setErrorCallbackFunction
When a SQL error occurs, this project will send a formatted (html or text) error message to a callback function specified through the setErrorCallbackFunction method. The callback function's name should be supplied as a string without parenthesis. As you can see in the examples provided above, you can specify an internal/built-in PHP function or a custom function you've created.
If no SQL errors are produced, this method will return an associative array of results.
update
If no SQL errors are produced, this method will return the number of rows affected by the UPDATE statement.