PHP code example of brainstormit / bitbuilder

1. Go to this page and download the library: Download brainstormit/bitbuilder 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/ */

    

brainstormit / bitbuilder example snippets


composer 

$this->db_type = 'mysql';
$this->db_host = 'localhost';
$this->db_name = 'qbtest';
$this->db_username = 'root';
$this->db_password = '';

$db = new Database();

// BITbuilder object
$b = new Builder($db);

$tbl = $b->table('users');

$record = $tbl->select('*')->fetchAll();

$fields = array('first_name', 'last_name', 'email');
$record = $tbl->select($fields)->fetchAll();

$record = $tbl->select(['first_name', 'email'])
              ->where('id', 89)
              ->fetchAll();

$record = $tbl->select(['first_name', 'email'])
              ->where('id', '<=', 51)
              ->fetch();

// AND operator
$record = $tbl->select(['first_name', 'email'])
              ->where('id', 23)
              ->and_('email', '!=', '[email protected]')
              ->fetchAll();
              
// OR operator
$record = $tbl->select(['first_name', 'email'])
              ->where('id', 69)
              ->or_('last_name', '=', 'Smith')
              ->fetchAll();

$record = $tbl->select('*')
              ->orderBy('id')
              ->fetchAll();

->orderBy('id', 'DESC')

$record = $tbl->select('*')
              ->GroupBy('email')
              ->fetchAll();

$record = $tbl->select('*')
              ->limit(5)
              ->fetchAl();

$insert = [
    'first_name' => 'John',
    'last_name' => 'Doe',
    'email' => '[email protected]'
];

$tbl->insert($insert);

$tbl->delete('id', 44);

$tbl->delete()
    ->where('id', 44)
    ->exec()

$update = array('first_name' => 'Crazy', 'last_name' => 'Frog');
$tbl->update($update, 'id', 59);

$update = array('first_name' => 'Crazy', 'last_name' => 'Frog');

$tbl->update($update)
    ->where('id', 59)
    ->exec();

// pictures table
$tbl = $b->table('pictures AS p');

$join = $tbl->select('*')
            ->join('users AS u', 'p.userid', 'u.id')
            ->fetchAll();

$tbl->raw('SELECT COUNT(*) FROM users')->fetchAll();

$tbl->raw('DELETE FROM users WHERE id = 77')->exec();