sy / mysql
MySQL database layer
Installs: 1 366
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 1
Requires
- php: >=7.4.0
- psr/simple-cache: ^1
- sy/db: ^1
- sy/template: ^2
Requires (Dev)
- phpunit/phpunit: ^10
README
MySQL database layer
Installation
Install the latest version with
$ composer require sy/mysql
Basic Usage
For production, a good idea is to store database connection settings in .ini files with restricted access. For example, my_setting.ini:
host = 127.0.0.1
dbname = my_database
username = my_username
password = my_password
<?php use Sy\Db\MySql\Crud; $crud = new Crud('user'); $crud->setConfig(parse_ini_file('my_setting.ini')); // Create $crud->create(['firstanme' => 'John', 'lastname' => 'Doe']); $crud->createMany([ ['firstanme' => 'John', 'lastname' => 'Doe'], ['firstanme' => 'John', 'lastname' => 'Wick'], ]); // Retrieve $user = $crud->retrieve(['id' => 3]); $users = $crud->retrieveAll(['LIMIT' => 10]); $users = $crud->retrieveAll(['LIMIT' => 10, 'OFFSET' => 10]); // Update $crud->update(['id' => 3], ['firstname' => 'Jane']); // Delete $crud->delete(['id' => 3]);