PHP code example of karelwintersky / arris.database

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

    

karelwintersky / arris.database example snippets




$config = new \Arris\Database\Config();

$config->setUsername('wombat')
    ->setPassword('wombatsql')
    ->setDatabase('47news')
    ->setSlowQueryThreshold(15);

$pdo = $config->connect();

// ИЛИ

$pdo = new \Arris\Database\Connector($config);

$sth = $pdo->prepare("SELECT COUNT(*) FROM articles");
$sth->execute();
var_dump($sth->fetchColumn());

// или

$sth = $pdo->query("SELECT COUNT(*) FROM articles");
var_dump($sth->fetchColumn());

// debug
var_dump($pdo->stats()->getSlowQueries());

var_dump($pdo->stats()->getLastQuery());

$config = new \Arris\Database\Config();
$config->option(PDO::ATTR_EMULATE_PREPARES, true);