PHP code example of kinoritech / fast-mysql

1. Go to this page and download the library: Download kinoritech/fast-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/ */

    

kinoritech / fast-mysql example snippets


use KinoriTech\FastMysql\Connection;

$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbname = 'example';

$db = new Connection($dbhost, $dbuser, $dbpass, $dbname);

$account = $db->query('SELECT * FROM accounts WHERE username = ? AND password = ?', 'test', 'test')->fetchArray();
echo $account['name'];

$account = $db->query('SELECT * FROM accounts WHERE username = ? AND password = ?', array('test', 'test'))->fetchArray();
echo $account['name'];

$accounts = $db->query('SELECT * FROM accounts')->fetchAll();

foreach ($accounts as $account) {
    echo $account['name'] . '<br>';
}

$db->query('SELECT * FROM accounts')->fetchAll(function($account) {
echo $account['name'];
});

$accounts = $db->query('SELECT * FROM accounts');
echo $accounts->numRows();

$insert = $db->query('INSERT INTO accounts (username,password,email,name) VALUES (?,?,?,?)', 'test', 'test', '[email protected]', 'Test');
echo $insert->affectedRows();

echo $db->query_count;


echo $db->lastInsertID();

$db->close();