PHP code example of sy / db
1. Go to this page and download the library: Download sy/db 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 / db example snippets
use Sy\Db\Gate;
// connection
$this->gate = new Gate('sqlite:' . __DIR__ . '/database.db');
// create table
$this->gate->execute('
CREATE TABLE test_table (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
)
');
// insert
$this->gate->insert('test_table', ['id' => 1, 'name' => 'hello']);
// select
$res = $this->gate->queryAll('SELECT * FROM test_table', PDO::FETCH_ASSOC);
print_r($res);