<?php
include('mysqli_handler.php');
// setting configuration on db
mysqli_handler::setDbConfiguration('localhost', 'user', 'password', 'db -> optional');
// connect to db, get instance
$mysqli_handler = mysqli_handler::getInstance();
// start simple
$mysqli_handler->query = "Select 1;";
$test = $mysqli_handler->getSingleResult();
var_dump($test);
// try sql injection
$mysqli_handler->query = "Select " . $mysqli_handler->Escape(" 'UNION; SELECT 2;");
var_dump($mysqli_handler->query);
// get multiple rows
$mysqli_handler->query = "SELECT * FROM `hashes`";
$test = $mysqli_handler->getResults();
var_dump($test);
// transaction test
$mysqli_handler->StartTransaction();
// insert
$mysqli_handler->query = "INSERT INTO hashes (`id`, `hash`) VALUES (NULL, '1');";
$test = $mysqli_handler->runQuery();
// its ok ?
var_dump($test);
// roolback all data
$mysqli_handler->RollbackTransaction();
// check is rollbacked
$mysqli_handler->query = "SELECT * FROM `hashes`";
$test = $mysqli_handler->getResults();
var_dump($test);
|