Skip to content

Latest commit

 

History

History
52 lines (36 loc) · 835 Bytes

README.md

File metadata and controls

52 lines (36 loc) · 835 Bytes

dbmodel

A class which makes easy database actions

Database connection

Initiaze class with an array which contains database information.

require_once __DIR__ . '/Model.php';


$dbConfig = [
    'dbHost' => 'localhost',
    'dbName' => 'db',
    'dbUser' => 'root',
    'dbPassword' => 'root',
    'charset' => 'utf8'
];

$model = new Model($dbConfig);

Select Examples

Get one row

$model->setTable('users')->select()->where('user_id','1');
$result = $model->get();

Get All Rows

$model->setTable('users');
$model->select();
$model->where('username','john', 'LIKE');
$result = $model->getAll();

Insert Examples

$model->setTable('users')->insert([
            'username' => 'User',
            'user_email' => '[email protected]',
        ]);

$userId = $model->insertId();