https://github.com/firehed/simpledb
A very simple PDO wrapper
https://github.com/firehed/simpledb
Last synced: about 1 year ago
JSON representation
A very simple PDO wrapper
- Host: GitHub
- URL: https://github.com/firehed/simpledb
- Owner: Firehed
- Created: 2018-02-16T22:54:24.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-19T22:46:13.000Z (over 8 years ago)
- Last Synced: 2025-02-13T22:26:58.234Z (over 1 year ago)
- Language: PHP
- Size: 5.86 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SimpleDb
A very simple PDO wrapper
Detailed documentation is coming Soon™.
## API
### `Firehed\SimpleDb\SimpleDb`
#### `public function __construct(PDO $pdo)`
Constructor
#### `public function select(string $query, array $params = []): Generator`
Pass in any SELECT query, with colon-prefixed `:placeholder`s.
For each of those placeholders, ensure `$params` has a matching key, including the colon.
The value can be any scalar type, _or an array of scalar types_ which will automatically be expanded when matched with an `IN()` clause.
Automatic `IN` support was the primary motivation behind this library.
#### `public function selectOne(string $query, array $params = []): array`
Same as above, but you get either the first row directly or a `NoResultError` will be thrown.
Nice for primary/unique key `SELECT`s.