tpojka / rel-sql
Simple DB connector for MySQL and PostgreSQL
dev-main / 0.9.x-dev
2021-08-09 12:32 UTC
Requires
- php: ~7.3||^8.0
- ext-pdo: *
- robmorgan/phinx: ^0.12.7
Requires (Dev)
- phpunit/phpunit: >=8.0
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2025-03-10 01:13:05 UTC
README
Package for connecting relational databases such are MySQL or PostgreSql. Code is in development phase until reaches version v1.
Structure
src/
tests/
Install
Via Composer
$ composer require tpojka/rel-sql
Usage
Be sure you have created database
// initialize migrations within project
php vendor/bin/phinx init
// set db credentials in newly created ./phinx.php file
mkdir -p db/migrations db/seeds
php vendor/bin/phinx create MyFirstMigration
php vendor/bin/phinx migrate -e development
// further explanation of how to use phinx can be checked in docs
// @see https://book.cakephp.org/phinx/0/en/contents.html
After you have table set rel-sql package can be used similarly to:
use Tpojka\RelSql\MysqlAdapter;
use Tpojka\RelSql\Db;
$mysqlAdapter = new MysqlAdapter($host, $name, $user, $pass);
$db = new Db($mysqlAdapter);
$db->connect();
$db->setTable('books');
// default is `id`
$db->setPrimaryKey('hungarian_notation_id');
return $db->getAll();
Testing
During tests table test_table
will be created
$ composer test
Security
Package is in dev phase and use in production is not advisable.
Credits
License
The MIT License (MIT). Please see License File for more information.