Login   Register  
PHP Classes
elePHPant
Icontem

File: query.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Vincenzo  >  SQL fast query  >  query.php  >  Download  
File: query.php
Role: Example script
Content type: text/plain
Description: Example and Mini HOWTO
Class: SQL fast query
Execute MySQL queries composed programmatically
Author: By
Last change:
Date: 7 years ago
Size: 3,843 bytes
 

Contents

Class file image Download
<?
include("sql_fast.inc.php");
$query=new sql_fast_query();//class
/*
Class use

Query methods:

out():Print the query;
execute():Execute the query;
destroy():Destroy the query.....USE EVER THIS AT THE END

****SIMPLE CONCATENATOR****
simple_where():Add WHERE at the query;
simple_and():Add AND at th query


****LIKE****
like($namefield,$value):This is a '$value';
like_s($namefield,$value):This is a '%$value';start
like_f($namefield,$value):This is a '$value%';end
like_s_f($namefield,$value):This is a '%value%';start and end

*/



/*

INSERT QUERY
-insert($nametable):
Use this if you think to do an insert query
-i_value($field):
Use this to add the field to select, use * for all fields
-values():
-****-*******-Use this after i_value to close the insert query!!-****-******-*
*/


//Start insert 
print "Example of insert:<br><br>";
$query->insert("example");//”INSERT INTO example”
//i_value 
$query->i_value("field","value");
$query->i_value("name","daniel");
$query->i_value("surname","loft");
$query->i_value("phone","02..");
$query->i_value("address","...");
$query->i_value("user","new");
$query->i_value("pass","mypass");
$query->i_value("active","NO");
$query->i_value("chmod","0777");
$query->i_value("folder","/home/daniel");
$query->i_value("img","loft.jpg");
$query->i_value("star","1");
$query->values();//this close the query
$query->out();//print the query
$query->destroy();//destroy;
//end insert

//***************************************************************************************************************
//Start update query
print "<br><br>Example of update:<br><br>";
/*

UPDATE QUERY
-update($nametable):
Use this if you wanna do an update query
-set($namefield,$newvaluetoassign);
Use this to set the field to change with tha value

*/

$query->update("user");
$query->set("name","daniel");
$query->set("surname","loft");
$query->simple_where();//WHERE
$query->like_s("user","jello");//this is like use '%jello' then i explain better this
$query->out();//print query
$query->destroy();//destroy;


//END update query

//***************************************************************************************************************
//Start delete query
print "<br><br>Example of delete:<br><br>";

/*
DELETE QUERY

$query->range($fiels,$from,$to):
this is the between 
BETWEEN $from AND $to

$query->in_var($field):
IN $namefield
$query->in($value);
*/


$query->delete();
$query->from("clienti");
$query->simple_where();
$query->range("data","luglio","settembre");
$query->simple_and();
$query->in_var("name");
$query->in("jello");
$query->in("pietro");
$query->in("luca");
$query->in("mauro");
$query->out();//print query
$query->destroy();//destroy;
//END delete query


//***************************************************************************************************************
//Start select distinct query
print "<br><br>Example of select distinct :<br><br>";

$query->select();
$query->distinct("data");
$query->distinct("num");
$query->distinct("password");
$query->from("dati_utenti");
$query->out();
$query->destroy();
//END distinct query
//***************************************************************************************************************


//***************************************************************************************************************
//Start select query
print "<br><br>Example of select  :<br><br>";

$query->select();
$query->select_var("*");
$query->from("dati_utenti");
$query->simple_where();
$query->like("user","jello");
$query->out();
$query->destroy();
//END distinct query
//***************************************************************************************************************


//

?>