delboy1978uk / bone-db
Db package for Bone Framework
Installs: 1 246
Dependents: 3
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.2
- delboy1978uk/barnacle: ^2.4
Requires (Dev)
- codeception/codeception: ^5.1
- codeception/module-asserts: ^3.0
- roave/security-advisories: dev-latest
README
PDO Connection package for Bone Framework
installation
bone-db comes pre-installed as part of the core Bone Framework packages. Install the skeleton project https://github.com/delboy1978uk/bonemvc
usage
You should already have a bone-db.php
config in your . Here is the Bone Framework Docker development environment settings:
<?php return [ 'db' => [ 'driver' => 'pdo_mysql', 'host' => 'mariadb', 'dbname' => 'awesome', 'user' => 'dbuser', 'password' => '[123456]', ], ];
The two databases and passwords are due to old legacy crap. Will be sorted soon! ;-)
usage
You can inject your PDO
connection into any of your classes via your Package registration class:
$pdoConnection = $c->get(PDO::class); // add a use statement too!
convenience interface and trait
You can quickly get a PDO connection getter and setter into your controllers by using Bone\Db\HasDbTrait
.
You can also implement Bone\Db\DbProviderInterface
and auto initialise it by passing into bone-controller Init class in
the add to container factory method.
reference
Official Manual https://www.php.net/manual/en/book.pdo.php
An awesome detailed book on PDO https://phpdelusions.net/pdo