PHP Classes

File: sample.php

Recommend this page to a friend!
  Classes of Josť M. 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: 5 years ago
Size: 1,030 bytes


Class file image Download
('DB_SERVER', 'localhost');
define('DB_USER', 'sqlazo_user');
define('DB_PASSWORD', 'sqlazo_password');

"./"); //the base class

$oTest = sqlazo_sel('mysql', DB_SERVER, DB_USER, DB_PASSWORD, DB_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