dboho / simple-database-api
Simple API for Database Access
v0.7.4
2020-07-16 14:01 UTC
Requires
- php: ~5.5 || ~7.0
- ext-pdo: *
Requires (Dev)
- phpunit/phpunit: ^5.0 || ^6.0 || ^7.0
- satooshi/php-coveralls: ~1.0
This package is auto-updated.
Last update: 2025-01-07 21:32:23 UTC
README
A simple API for Database Access
Features
- Simple API
- prevent SQL injection with automatic whitelist column filter and pdo prepared statements
Install with Composer
$ composer require dboho/simple-database-api
Usage
# select $result = $da->select('books', ['title'], ['author'=>'Rasmus Lerdorf']); echo(json_encode($result)); # insert $da->insert('books', ['title'=>'Using the New DB2', 'author'=>'Don Chamberlin']); # update $da->update('books', ['price'=>9.80], ['id'=>1023]); # delete $da->delete('books', ['id'=>1021]);
Automatic Whitelist Column Filter
To prevent SQL injection all attributes that are used as column names will be filtered with a whitelist. This whitelist is build for each queried database table.
Example
Books Table
Whitelist for the books table will contain id, title, author and price.