Example #1
0
<?php

if (!defined('_LIB')) {
    define('_LIB', realpath(dirname(__FILE__) . '/../') . '/src/_Libs/');
}
require_once _LIB . '/_Db.php';
use _\_Db;
$host = 'localhost';
$username = '******';
$password = '******';
$dbName = 'foo';
$db = new _Db($host, $username, $password, $dbName);
$id = 1;
$escapedId = $db->escape($id);
$sql = "SELECT * FROM bars WHERE id='{$escapedId}'";
$db->query($sql);
if ($row = $db->getRow()) {
    $thing = $row['col_name'];
}
echo $thing;
Example #2
0
 public function testStaticGetRow()
 {
     // Test 3
     $this->clearDb();
     $this->insertRows(1000);
     $db = new _Db();
     for ($i = 0; $i < 1000; $i++) {
         $sql = "SELECT * FROM _testtable WHERE _key='key_{$i}'";
         $db->query($sql);
         $row = $db->getRow();
         $this->assertEquals("val_{$i}", $row['_value']);
     }
 }