PHP Classes

DBConnect PHP Database Query Builder: Execute database queries from configuration files

Recommend this page to a friend!
  Info   View files Documentation   View files View files (11)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 116 This week: 1All time: 9,536 This week: 560Up
Version License PHP version Categories
db-query-builder 1.0.0MIT/X Consortium ...5PHP 5, Databases, Configuration
Description 

Author

This package can execute database queries from configuration files.

It can connect to a database server using PDO using parameters read from a configuration file defined in the YAML format.

The class can also execute SQL queries and retrieve the query results.

The SQL queries may also be loaded from a separate configuration script that assigns constants with certain names to SQL query strings.

Each SQL query has a name that is the same name of the PHP constant that has the SQL query string value.

The class can also execute named SQL queries passing given parameters and fetch the results into arrays.

Innovation Award
PHP Programming Innovation award nominee
June 2022
Number 2
Most PHP applications need to connect to a database and execute SQL queries to store and retrieve data.

Usually, developers define the SQL queries as strings in the PHP code that performs those queries when executed.

If you need to update the queries to improve the features, you must change the PHP code that defines those queries.

This package provides a different alternative to define the queries that the PHP code of your applications needs to execute.

It allows defining the queries in the PHP configuration scripts that define the queries as named constants.

This approach allows developers to find the queries they need to update faster when they want to improve their application features.

This way also makes application maintenance easier because the developers may only need to change configuration files defined separately from the application code.


Manuel Lemos
Picture of Sergey Kol'miller
  Performance   Level  
Name: Sergey Kol'miller <contact>
Classes: 5 packages by
Country: Russian Federation Russian Federation
Age: 40
All time rank: 354698 in Russian Federation Russian Federation
Week rank: 416 Up24 in Russian Federation Russian Federation Up
Innovation award
Innovation award
Nominee: 3x

Documentation

This is a simple module that returns an object of the PDO class. MySql.

_Dependecies_ `require php : ^7.0, symfony/yaml : ^4.0` `reguire-dev: phpunit/phpunit : ^7.0` "phpunit/dbunit": "^4.0"

_Instalation_ -$ composer require kolserdav/dbconnect -$ composer update

{ -rename file database-example.yaml to database.yaml

-copy folder config in root of your project  
-add in file database.yaml self variables

} or call: -$php vendor/kolserdav/dbconnect/install

_Using_

use Avir\Database\Modules\DB;

$db = new DB;

In order to get PDO:

$pdo = $db->getPDO();

To get STMT:

$db->getStmt($query,[$values] = array());

To send a request:

$db->stmtCall($stmt, $fetchRule, $fetchOption);

Or insert your queries in to /config/queries.php and use:

$db->callDB($queryName, [$values] = array(), $fetchOption = 0, $fetchRule = 'fetch')

To fine-tune the selection rules: need call to FetchRule::class methods

hisFetch(),hisFetchColumn()...

By results of work, I will improve this module...


  Files folder image Files  
File Role Description
Files folder imageconfig (2 files)
Files folder imagesrc (1 directory)
Files folder imagetests (1 directory)
Plain text file composer.json Data Auxiliary data
Plain text file composer.lock Data Auxiliary data
Plain text file install Aux. Installation script
Plain text file README.md Doc. Documentation

  Files folder image Files  /  config  
File Role Description
  Plain text file database-example.yaml Data Auxiliary data
  Plain text file queries.php Aux. Auxiliary script

  Files folder image Files  /  src  
File Role Description
Files folder imageModules (4 files)

  Files folder image Files  /  src  /  Modules  
File Role Description
  Plain text file DB.php Class Class source
  Plain text file DbConnect.php Class Class source
  Plain text file FetchRules.php Class Class source
  Plain text file QueryPrepare.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imagedbtest (1 file)

  Files folder image Files  /  tests  /  dbtest  
File Role Description
  Plain text file Test.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:116
This week:1
All time:9,536
This week:560Up