PHP code example of develhopper / qbuilder

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

    

develhopper / qbuilder example snippets



namespace models;

use QB\QBuilder as Model;

class Customer extends Model{
    // table name
    protected $table="customers";
    
    // primary key
    protected $primary="customerNumber";

    // relations
    public function payments(){
        return $this->hasMany(Payment::class,false);
    }
}


use QB\Migration\Migration;
use QB\Migration\Column;
use Denver\Env;

Env::setup(__DIR__."/.env");

$users = Migration::create_table('users', Column::IntegerField('id', ['primary' => true]),
    Column::StringField('username',25,['unique' => true]),
    Column::StringField('email',255,['unique' => true]),
    Column::StringField('password',255)
);

$profile = Migration::create_table('profile', Column::IntegerField('id', ['primary']),
    Column::StringField('first_name', 30),
    Column::StringField('last_name', 30),
    Column::IntegerField('user_id', ['connect' => $users->id, 'on_delete' => 'cascade', 'on_update' => 'restrict'])
);