PHP code example of walnut / lib_dbquery_pdo

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

    

walnut / lib_dbquery_pdo example snippets


$connector = new PdoConnector('sqlite::memory:', '', '');
$executor = new PdoQueryExecutor($connector);

$executor->execute("SELECT 1 AS val")->singleValue(); //1
$executor->execute("SELECT 1 AS val")->first(); //['val' => '1'],
$executor->execute("SELECT 1 AS val")->all(); //[['val' => '1']]
$executor->execute("SELECT 1")->collectAsList()->all(); //[['val' => '1']]
$executor->execute("SELECT 1 AS k, 1 AS val")->collectAsHash()->all(); //[1 => ['val' => '1']]
$executor->execute("SELECT 1 AS k, 1 AS val")->collectAsTreeData()->all(); //[1 => [['val' => '1']]],