PHP code example of sy / mysql
1. Go to this page and download the library: Download sy/mysql library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sy / mysql example snippets
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]);