tgrj / tweb_db
minimalistic db handler
v0.0.1
2026-03-03 21:21 UTC
Requires
- php: >=8.0
- tgrj/tweb_core: >=0.0.5
Requires (Dev)
- phpunit/phpunit: ^12.0
This package is auto-updated.
Last update: 2026-03-03 21:23:32 UTC
README
minimalistic db handler
Idea
It's no database abstraction framework or so. It's rather some kind of wrapper for some PHP functions and some pre-defined functions doing some very basic database work. The usage of the database later in the project will get the PDO from this module and use it for further actual database handling.
Usage
- tweb_get_pdo(string $config_key = 'db')
$config_keyis a tweb_config key, under which the db array config is stored. it should at least contain the key type, which is either sqlite or mysql. For the first one the config array should also contain file. For mysql it should contain host, dbname, username, password. The function will return a PDO instance on success, or throw an exception otherwise.
- tweb_execute_sql_file(\PDO $pdo, string $sql_file)
- With that function you can execute SQL code from the given file.