1. Go to this page and download the library: Download hindbiswas/quebee library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hindbiswas / quebee example snippets
use Hindbiswas\QueBee\Query;
$aliased_cols = ['alias1' => 'column1', 'alias2' => 'column2', 'column3' => 'column3'];
$query = Query::select($aliased_cols)->from('table')->build();
// Resulting SQL query
// SELECT column1 AS alias1, column2 AS alias2, column3 AS column3 FROM table;
use Hindbiswas\QueBee\Query;
$query = Query::select(['column1', 'column2'])
->from('table')
->where('column1', 'value')
->orderBy('column2', 'desc')
->limit(10)
->build();
// Resulting SQL query
// SELECT column1, column2 FROM table WHERE column1 = 'value' ORDER BY column2 DESC LIMIT 0, 10;
$query = Query::delete('table')->where('column1', 1, 'gt')->build() // Here `gt` is alias for `>`
// Resulting SQL query
// DELETE FROM table WHERE column1 > '1';
use Hindbiswas\QueBee\Col;
use Hindbiswas\QueBee\Table;
use Hindbiswas\QueBee\Table\Values\DefaultVal;
$usersTable = Table::create('users')->columns([
'id' => Col::integer(11)->unsigned()->pk()->ai(),
'username' => Col::varchar()->unique(),
'email' => Col::varchar()->unique(),
'password' => Col::varchar(),
'is_superadmin' => Col::integer(2)->default('0'),
'create_time' => Col::dateTime()->default(DefaultVal::CURRENT_TIME),
'update_time' => Col::dateTime()->setOnUpdate()->default(DefaultVal::CURRENT_TIME),
]);
$query = $usersTable->build();
// Resulting SQL query
// CREATE TABLE IF NOT EXISTS users (`id` INT(11) UNSIGNED NULL AUTO_INCREMENT, `username` VARCHAR(255) NOT NULL, `email` VARCHAR(255) NOT NULL, `password` VARCHAR(255) NOT NULL, `is_superadmin` INT(2) NOT NULL DEFAULT '0', `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `update_time` DATETIME on update CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT users_PK PRIMARY KEY (id), CONSTRAINT username_UC UNIQUE (`username`), CONSTRAINT email_UC UNIQUE (`email`)) ENGINE = InnoDB;
use Hindbiswas\QueBee\Col;
use Hindbiswas\QueBee\Table;
use Hindbiswas\QueBee\Table\Values\DefaultVal;
use Hindbiswas\QueBee\Table\Values\FK;
// $usersTable = create a table to constrain with
$table = Table::create('tokens')->columns([
'id' => Col::integer()->unsigned()->pk()->ai(),
'selector' => Col::varchar(),
'hashed_validator' => Col::varchar(),
'user_id' => Col::integer(11)->unsigned(),
'expiry' => Col::dateTime(),
])->foreign('user_id')->onDelete(FK::CASCADE)->reference($usersTable, 'id');
// Resulting SQL query
// CREATE TABLE IF NOT EXISTS tokens (`id` INT UNSIGNED NULL AUTO_INCREMENT, `selector` VARCHAR(255) NOT NULL, `hashed_validator` VARCHAR(255) NOT NULL, `user_id` INT(11) UNSIGNED NOT NULL, `expiry` DATETIME NOT NULL, CONSTRAINT tokens_PK PRIMARY KEY (id), FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE) ENGINE = InnoDB;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.