Login   Register  
PHP Classes
elePHPant
Icontem

File: sample.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of José Manuel Carnero  >  SQLazo  >  sample.php  >  Download  
File: sample.php
Role: Example script
Content type: text/plain
Description: Usage example
Class: SQLazo
MySQL database abstraction access layer
Author: By
Last change: project name changed
Date: 2011-05-30 02:20
Size: 1,030 bytes
 

Contents

Class file image Download
<?php
define
('DB_SERVER''localhost');
define('DB_USER''sqlazo_user');
define('DB_PASSWORD''sqlazo_password');
define('DB_DATABASE','sqlazo_database');

include_once(
"./class.sqlazo.inc"); //the base class

$oTest sqlazo_sel('mysql'DB_SERVERDB_USERDB_PASSWORDDB_DATABASE); //connect to DB_SERVER with credentials given in constants
//don't change the first parameter; actually the class only suppport MySQL (or MySQLi, automatic selection)

$var1 'val1';
$var2 'v';

//$oTest->consulta("SELECT * FROM table"); //execute de query (simple query)
$oTest->consulta("SELECT field FROM table WHERE field = '%s' OR field LIKE '%%%s%%'", array($var1$var2), 5); //execute de query with parameters and limited to the first 5 rows

while($oTest->leeFila()){ //read a row
    
echo($oTest->aFila['field']."<br/>\n"); //show a field
}

var_dump($oTest->aTiempos); //show times (conection, consult, ...)
if($oTest->getError()) var_dump($oTest->getError()); //show errors

$oTest->desconectar(); //disconnect
?>