PHP Classes

File: LQueryBU/MANUAL.txt

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  Classes of Xavier Pérez  >  LQueryBU  >  LQueryBU/MANUAL.txt  >  Download  
File: LQueryBU/MANUAL.txt
Role: Documentation
Content type: text/plain
Description: Manual
Class: LQueryBU
SQL and PHP business units
Author: By
Last change: No login
Date: 5 years ago
Size: 4,620 bytes


Class file image Download

1) Introduction
2) Configuration
3) Options
4) Examples

1) Introduction

LQueryBu means Light Query Business Unit, created to speed development and to
mantain business logic separated from controlers.

The MVC concept are translated to BMVC, Business, Model, View and Controlers
I don't like the ADODB schema and other SETTERS and GETTERS, I think that all must to be more simple.

LQueryBU makes a fusion between a query and it's actions.
Traditional models have it's own TABLEMODEL, all functions related to the actions with this table.
LQueryBU simplify it, having a file for each action, avoiding large TABLEMODEL files.
Also, increase speed, only need a small file, instead of loading a large library.

LQueryBU uses PDO as a generic wrapper, but can be configured to use any other wrapper.

2) Configuration


To install the standalone examples, you must to:

	Edit your apache conf.
	Crete and point your virtual host (DocumentRoot) to the uncompressed "www" directory (example:  lquerybu.local)
    Add or check phtml type:
    	Addtype application/x-httpd-php .phtml
    Add or check php type:
    	Addtype application/x-httpd-php .php
    Edit your php.ini conf.
    Add or check PDO:
		For PHP 5.2:
		For PHP 5.3:

	Load the example database into your database:    
    	Load /LQUeryBU/examples_db/wolrd_db/world.sql into your database

	Edit /LQueryBU/database.php and change DB connection data

	Now, you can open your browser and type the virtual host name (above):  http://lquerybu.local

3) Options

LQueryBU can execute any sql commands, SELECT, INSERT, UPDATE, DELETE, REPLACE, etc... 
including procedures. You can do with transaction or without it.

Also, you can concatenate commands, Example: Multiple updates, if some of them fails, rollback, else commit.

Also, you can insert functions. Functions that can be called from any other unit or any place in a model.
For example, you need your own URFRIENDLY FUNTION CONVERTER when insert/update a product record, then you
must to create the fMakeUrl.php unit, and you can call it from the same unit that are updating/inserting records.

IMPORTANT:  All unit files must to be coded in UTF-8


LQueryBU can save all information for debugging, you only have to enable it in the main config.php (LQUERYBU_SHOW_SQL_COMMANDS).
When instantiate the LQueryBU class, you must to set the "debugQuery" atttribute to TRUE.
See :
		$LQueryBU = new LQueryBU(); 
		$result = $LQueryBU->getDataQuery("/example1",array("LIMIT_FROM" => 0,"LIMIT_TO"=>10,"ORDER_BY" => 1,"ASCDESC"=>"ASC"));

After enabling the debugger, you can retrive all formatted information with the dumpDebugQuery function:

		$debugInformation = $LQueryBU->dumpDebugQuery();

You also can get only queries executed for profiler purpouses:

		$queryInformation = $LQueryBU->dumpQueries();

The "dumpQueries" function return an array of all queries executed, with it's elapsed time:

	$dumpQuery = array ( $numQuery => array ($queryCommand,$elapsedTime)); 


You can use other wrapper, only need to modify LQueryBU_DBI, change extends from your wrapper, and implements
the general functions with your own.

Functions used:
	public function DBprepare($sql);
	public function DBexecute();
	public function DBfetchAll();
	public function DBrowCount();
	public function DBlastInsertId();
	public function DBcolumnCount();
	public function DBgetColumnMeta($column);
	public function DBbeginTransaction();
	public function DBcommit();
	public function DBqueryOne($sql);
	public function DBrollBack();

4) Examples

The Standalone comes with four examples, three of them showing a tablegrid and it's possibilities
and the fourth, a recordgrid example, calling a UPDATE unit.

The examples comes with NavVars.php class, as makes more readable the base code.