brunogasparetto / query-builder
Simplistic Query Builder using PDO
1.0.2
2019-04-04 13:39 UTC
Requires
- php: >=5.6
Requires (Dev)
- phpunit/phpunit: ^5.7 || ^7
This package is auto-updated.
Last update: 2024-11-05 02:23:10 UTC
README
Database Query Builder
Simplistic Query Builder made a long time ago for fun.
Installation
The package is available on Packagist. You can install it using Composer
$ composer require brunogasparetto/query-builder
Example
$database = new QueryBuilder\Database([ 'driver' => 'mysql', 'charset' => 'utf8', 'host' => 'localhost', 'dbname' => 'databaseName', 'user' => 'user', 'password' => 'password', 'fetchMode' => PDO::FETCH_OBJ, // Default ]); $query = $database ->select('column') ->from('table') ->whereOpen() ->where('column1', '=', 5) ->where('column2', '=', 'Name') ->whereClose() ->whereOrOpen() ->where('column1', '=', 10) ->where('column2', '=', 'Other Name') ->whereOrClose(); echo (string) $query; $query ->select('coluna2', 'coluna3') ->join('tabela2') ->on('table.id', '=', 'tabela2.id') ->on('userid', '=', 5) ->where('tabela2.coluna2', '=', true); echo (string) $query;