Download the PHP package adrian0350/simple-pdo-wrapper without Composer
On this page you can find all versions of the php package adrian0350/simple-pdo-wrapper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download adrian0350/simple-pdo-wrapper
More information about adrian0350/simple-pdo-wrapper
Files in adrian0350/simple-pdo-wrapper
Package simple-pdo-wrapper
Short Description As its name suggests, it is a simple PDO wrapper to facilitate/simplify/beautify sql syntax and PDO usage.
License MIT
Homepage https://github.com/Adrian0350/SimplePDOWrapper
Informations about the package simple-pdo-wrapper
Introduction
SimplePDOWrapper's purpose is to help you handle simple database actions with a reduced amount of code as well as writting less-messy code following a simple structure.
You can:
- Save
- Update
- Delete (with conditions)
- Delete all (without conditions)
- Find one
- Find all
- Set database (switch on the fly)
- Error handling through public var @errors
Dependencies
PHP Version
This class is compatible with PHP 5.0 and above due to the PHP PDO dependency.
Installing
Add this library to your Composer configuration. In composer.json:
Or
If you're using bash.
Usage
For usage just call the methods from your SimplePDOWrapper instance object.
Options param
Options are available with
- conditions
- And more complex clauses:
- limit
- fields
- order
Save New Entry
Update New Entry
findOne & findAll
This methods receive 3 params in total, entity (table), options (see above) and assoc (boolean) to get an associative array or STDClass object.
delete & deleteAll
The only difference between delete and deleteAll is that 'delete' receives the options argument with 'conditions'.
Switch database
Just like instantiating the class.
// As I mentioned before update method will return a boolean value. $updated = $SimplePDOWrapper->update('users', $update, array( 'conditions' => array( 'id' => $user_saved['id'] ) ))
// Watching errors if (!$updated || $SimplePDOWrapper->errors) { var_dump($SimplePDOWrapper->errors['code']); var_dump($SimplePDOWrapper->errors['message']); }