PHP code example of linkuha / db

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

    

linkuha / db example snippets


public function __invoke(...)
{
    $configDb = $container->get('config')['db'];
    $configEnv = $container->get('config')['environment'];    // server environment
    
    // ...

    return MysqliManager::getInstance(
        $configResult['db_user'],
        $configResult['db_pass'],
        $configResult['db_name'],
        $configResult['db_host'],
        $configResult['db_port'],
        true
    );
}

use Phinx\Migration\AbstractMigration;

class InitMigration extends AbstractMigration
{
    public function up()
    {
        $sqlFilePath = __DIR__ . "/../init.sql";

        $result = PDOSqlFileImporter::tryImport($this->getAdapter()->getConnection(), $sqlFilePath);

        if ($result["status"] === "fail") {
            throw new \Exception($result["status"] . ": " . $result["details"]);
        }
        return true;
    }
...

$handlerSocket = HandlerSocketMySql::getInstance($configResult['db_host'], $configResult['db_name']);

$cols = "msg,url,ua,date";
$vals = array($msg, $url, $ua, $date);

$handlerSocket->insert("JsErrorsLog", $cols, $vals);