PHP Classes
elePHPant
Icontem

Simple SQL query manager: Compose SQL queries read from template files

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   View files Example   View files View files (14)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2015-04-04 (3 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 558 This week: 1All time: 5,066 This week: 1,131Up
Version License PHP version Categories  
sql_query_manager 1.0.3GNU General Publi...5.3PHP 5, Databases, Templates, Security
Description Author  

This class can compose SQL queries read from template files.

It can read and process a template file that defines a SQL query.

The class replaces placeholder using values assigned to class variables.

The values are encoded before replacing in the template according to the variable type.

The processed query template is returned as a string.

Picture of Rafal Przetakowski
Name: Rafal Przetakowski <contact>
Classes: 3 packages by
Country: Poland Poland
Age: 37
All time rank: 184948 in Poland Poland
Week rank: 268 Up10 in Poland Poland Up

Details provided by the author  
# Simple SQL query manager

A simple SQL query manager with option to secure queries by setting parameter type. 

It uses classes which represents siple var types as string, integer etc... and own classes 
like secureString, email etc...

To better secure queries, you can create your own var types classes, for example password or phone

## Examples

SQL query example:

	SELECT example1 FROM exampleTable WHERE example = {value->secureString}

PHP example:

	<?php

	require_once 'sqlquery.php';

	echo "Example with a correct data:<br>";
	try {
		$query = new sqlQuery("sqlExample");
		$query->value = 'TEST_VALUE';

		// if you set a string value it will be set as 0 (zero) because (integer)'ddd' = 0 (zero)
		$query->value2 = 11;

		// polish vat no algoritm allows to use 1111111111 vat number
		// if you want to check an european vat no see:
		// http://www.phpclasses.org/package/2280-PHP-Check-if-a-European-VAT-number-is-valid.html
		$query->vatno = '1111111111';

		$query->valueArrayWithoutAtype = array('one', 'two', 'tree');
		$query->valueWithoutParamType = "value Without Param Type";

		echo $query->getQuery();
	} catch (Exception $ex) {
		echo $ex->getMessage();
	}

	echo "<br><br>Example with incorrect data:<br>";
	try {
		$newQuery = new sqlQuery("sqlExample");
		$newQuery->value = 'TEST_VALUE';
		$newQuery->value2 = 11;

		// incorrect polish vat no
		$newQuery->vatno = '1212111211';

		$query->valueArrayWithoutAtype = array('one', 'two', 'tree');
		$query->valueWithoutParamType = "value Without Param Type";
		echo $newQuery->getQuery();
	} catch (Exception $ex) {
		echo $ex->getMessage();
	}

	echo "<br><br>Example with conditioned value:<br>";
	try {
		$query = new sqlQuery("sqlExample");
		$query->value = 'TEST_VALUE';

		// if you set a string value it will be set as 0 (zero) because (integer)'ddd' = 0 (zero)
		$query->value2 = 11;
		$query->vatno = '1111111111';

		$query->valueArrayWithoutAtype = array('one', 'two', 'tree');
		$query->valueWithoutParamType = "value Without Param Type";

		// condition !empty()
		$query->notEmptyValue = 1;

		echo $query->getQuery();
	} catch (Exception $ex) {
		echo $ex->getMessage();
	}
  Files folder image Files  
File Role Description
Files folder imageSQL (1 file)
Files folder imagevartypes (9 files)
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file LICENSE Data Auxiliary data
Accessible without login Plain text file README.md Doc. Auxiliary data
Plain text file sqlquery.php Class Class source

  Files folder image Files  /  SQL  
File Role Description
  Accessible without login Plain text file sqlExample.sql Data Auxiliary data

  Files folder image Files  /  vartypes  
File Role Description
  Plain text file boolean.php Class Class source
  Plain text file date.php Class Class source
  Plain text file double.php Class Class source
  Plain text file email.php Class Class source
  Plain text file float.php Class Class source
  Plain text file integer.php Class Class source
  Plain text file nip.php Class Class source
  Plain text file secureString.php Class Class source
  Plain text file string.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%Total:558All time:5,066
 This week:1This week:1,131Up