Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Kacper Rowinski  >  MySQLi Handler  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example usage
Class: MySQLi Handler
MySQL database access wrapper using the MySQLi
Author: By
Last change:
Date: 2012-02-26 13:38
Size: 1,081 bytes
 

Contents

Class file image Download
<?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);