Skip to content

kivancagaogluu/dbmodel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

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();

About

A class which makes easy database actions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages