PHP Classes
elePHPant
Icontem

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

Recommend this page to a friend!
  Info   View files View files (21)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2016-07-08 (21 days ago) RSS 2.0 feedNot yet rated by the usersTotal: 578 This week: 1All time: 5,050 This week: 879Up
Version License PHP version Categories
sql_query_manager 1.0.7GNU 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
  Performance   Level  
Name: Rafal Przetakowski <contact>
Classes: 4 packages by
Country: Poland Poland
Age: 38
All time rank: 136838 in Poland Poland
Week rank: 161 Up5 in Poland Poland Up

Details
# 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}

### Example with a correct data:

	`<?php

	use Beeflow\SQLQueryManager\SQLQuery

	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();
	}`

### Example with incorrect data:

    `<?php

    use Beeflow\SQLQueryManager\SQLQuery

	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();
	}`

### Example with conditioned value:

    `<?php

    use Beeflow\SQLQueryManager\SQLQuery

	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 imageException (2 files)
Files folder imageTests (2 files, 1 directory)
Files folder imageVartypes (9 files)
Accessible without login Plain text file autoload.php Aux. Auxiliary script
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Data Auxiliary data
Accessible without login Plain text file phpunit.xml.dist 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  /  Exception  
File Role Description
  Plain text file EmptyQueryException.php Class Class source
  Plain text file NoQueryException.php Class Class source

  Files folder image Files  /  Tests  
File Role Description
Files folder imageSQL (2 files)
  Accessible without login Plain text file bootstrap.php Aux. Auxiliary script
  Plain text file SQLQueryTest.php Class Class source

  Files folder image Files  /  Tests  /  SQL  
File Role Description
  Accessible without login Plain text file emptyQuery.sql Data Auxiliary data
  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:578
This week:1
All time:5,050
This week:879Up