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 (23)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-03-17 (10 days ago) RSS 2.0 feedNot enough user ratingsTotal: 611 This week: 3All time: 4,922 This week: 267Up
Version License PHP version Categories
sql_query_manager 1.0.16GNU 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.

  Performance   Level  
Name: Rafal Przetakowski <contact>
Classes: 4 packages by
Country: Poland Poland
Age: 38
All time rank: 126534 in Poland Poland
Week rank: 62 Up2 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

## Install

### composer

    $ composer require "beeflow/sqlquerymanager:dev-master"

### GIT
    
    $ git clone https://github/beeflow/

## Examples

### SQL query example:

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

### Example with new method of calling SQL files

    `<?php
    
    	use Beeflow\SQLQueryManager\SQLQuery
    
    	try {
    	    $query = new SQLQuery();
            $query->sqlExample([
                    'value'                  => 'TEST_VALUE',
                    'value2'                 => 11,
                    'vatno'                  => '1111111111',
                    'valueArrayWithoutAtype' => array('one', 'two', 'tree')
            ]);
             
            echo $query->getQuery();
    	} catch (Exception $ex) {
            echo $ex->getMessage();
    	}`
    
    
### 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 (11 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 BFBoolean.php Class Class source
  Plain text file BFByte.php Class Class source
  Plain text file BFDate.php Class Class source
  Plain text file BFDouble.php Class Class source
  Plain text file BFEmail.php Class Class source
  Plain text file BFFloat.php Class Class source
  Plain text file BFInteger.php Class Class source
  Plain text file BFNip.php Class Class source
  Plain text file BFPsqlSecureString.php Class Class source
  Plain text file BFSecureString.php Class Class source
  Plain text file BFString.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:611
This week:3
All time:4,922
This week:267Up