https://github.com/phppackage/pdo-wrapper
Yet another PDO wrapper which extends the PDO class and adds some additional suger.
https://github.com/phppackage/pdo-wrapper
composer-package pdo wrapper yet-another
Last synced: about 1 month ago
JSON representation
Yet another PDO wrapper which extends the PDO class and adds some additional suger.
- Host: GitHub
- URL: https://github.com/phppackage/pdo-wrapper
- Owner: phppackage
- License: mit
- Created: 2018-02-06T16:56:56.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-07T10:10:45.000Z (almost 8 years ago)
- Last Synced: 2025-07-23T08:53:13.688Z (6 months ago)
- Topics: composer-package, pdo, wrapper, yet-another
- Language: PHP
- Size: 39.1 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
## PDO Wrapper
[](https://travis-ci.org/phppackage/pdo-wrapper)
[](https://styleci.io/repos/120492220)
[](https://scrutinizer-ci.com/g/phppackage/pdo-wrapper/?branch=master)
[](https://scrutinizer-ci.com/g/phppackage/pdo-wrapper/code-structure/master/code-coverage)
[](https://github.com/phppackage/pdo-wrapper/releases)
[](https://packagist.org/packages/phppackage/pdo-wrapper)
Yet another PDO wrapper which extends the PDO class and adds some additional suger.
## Install
Require this package with composer using the following command:
``` bash
$ composer require phppackage/pdo-wrapper
```
### Usage example:
PDO::ERRMODE_EXCEPTION
]
);
// or default to an sqlite file
$db = new PDO();
// get database info
$info = $pdo->info();
// get databases
$databases = $pdo->databases();
// get tables
$tables = $pdo->tables();
// create a database
$pdo->createDatabase('test');
// get database name (from dsn)
$name = $pdo->getDatabaseName();
// export database (mysql only)
$filename = $pdo->export('./'); // ./ = destination folder
// import database (mysql only)
$pdo->import('./backup.sql.gz');
// create
$pdo->run('INSERT INTO table_name (name) VALUES (?)', ['foo']);
// create - multi
$pdo->run('INSERT INTO table_name (name) VALUES (?)', [['foo'], ['bar'], ['baz']]);
// retrieve - PDOStatement
$stmt = $pdo->run('SELECT * FROM table_name');
$stmt = $pdo->run('SELECT * FROM table_name WHERE id = ?', [1]);
$stmt = $pdo->run('SELECT * FROM table_name WHERE id = :id', ['id' => 1]);
// retrieve - single row
$result = $pdo->row('SELECT * FROM table_name WHERE id = ?', [1]);
$result = $pdo->row('SELECT * FROM table_name WHERE id = :id', ['id' => 1]);
// retrieve - single cell
$result = $pdo->cell('SELECT column FROM table_name WHERE id = ?', [1]);
$result = $pdo->cell('SELECT column FROM table_name WHERE id = :id', ['id' => 1]);
// retrieve - all array
$result = $pdo->all('SELECT * FROM table_name');
$result = $pdo->all('SELECT * FROM table_name WHERE id = ?', [1]);
$result = $pdo->all('SELECT * FROM table_name WHERE id = :id', ['id' => 1]);
// update
$pdo->run('UPDATE table_name SET column = ? WHERE id = ?', ['foo', 1]);
// delete
$pdo->run('DELETE FROM table_name WHERE id = ?', [1]);
// .. and all other standard PDO functionality
## Testing
``` bash
$ composer test
```
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## Credits
- [Lawrence Cherone](http://github.com/lcherone)
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE) for more information.