PHP code example of nightlinus / oracle-db

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

    

nightlinus / oracle-db example snippets



use nightlinus\OracleDb\Database;

$db = new Database("USER", "password", "DEV");


$db->config('connection.cache', true);


$db->config('connection.cache', false);

$sql = 'SELECT * FROM DUAL';
$statement = $db->prepare($sql);


$sql = 'SELECT * FROM DUAL';
$statement = $db->query($sql);


$sql = 'SELECT *, :b_var FROM DUAL';
$statement = $db->prepare($sql);
$statement->bind(['b_var' => 1]);


$sql = 'SELECT *, :b_var FROM DUAL';
$statement = $db->query($sql, ['b_var' => 1]);


$sql = 'SELECT * FROM customers';
$statement = $db->query($sql);

foreach($statement as $row) {
  var_dump($row);
}

$statement->execute() //Делаем вохможным получение данных повторно
          ->setReturnType($statement::RETURN_ITERATOR); //из fetch* функция возвращаем итератор, а не готовый массив
foreach($statement->fetchMap() as $map) {
  var_dump($map['123'])
}