PHP code example of readdle / fqdb

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

    

readdle / fqdb example snippets


$fqdb = new \Readdle\Database\FQDB('mysql:host=localhost;dbname=test', 'user', 'password');

// parses ~/.my.cnf
$fqdb = FQDBProvider::dbWithMyCnf($database); 

// dsn example: mysql:host=127.0.0.1;dbname=database;charset=utf8mb4
$fqdb = FQDBProvider::dbWithDSN($dsn, $user, $password);

$fqdb = FQDBProvider::dbWithMySQLHostUserPasswordDatabase($host, $user, $password, $database);


$fqdb = new \Readdle\Database\FQDB('mysql:host=localhost;dbname=test', 'user', 'password');

$value = $fqdb->queryValue("SELECT 2+2");
// $value == 4

$hash = $fqdb->queryAssoc("SELECT id, content FROM idcontent WHERE id=13");
// $hash = ['id' => 13, 'content'=>'...'] 

// to use a custom connector you can register it before instantiating the FQDB
\Readdle\Database\FQDB::registerConnector(\Readdle\Database\ConnectorInterface $connector);
$fqdb = new \Readdle\Database\FQDB($optionSupportedByYourConnector);