Database is a class for database connection, disconnection, table creation and deletion.
- Create Table
Database::createTable("product", "
CREATE TABLE IF NOT EXISTS product(
id INT(6) AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
description VARCHAR(255) NULL,
price DECIMAL NOT NULL,
image LONGBLOB NULL,
created_at TIMESTAMP,
deleted_at DATETIME DEFAULT NULL,
PRIMARY KEY(id)
)");
- Drop Table
Database::dropTable($tblName);
DB_Table is a class for retrieving, inserting, updating and deleting rows in the database table.
- SELECT ALL
DB_Table::all('roles');
DB_Table::all('roles', 'assoc');
DB_Table::all('roles', 'array');
DB_Table::all('roles', 'object');
- SELECT WHERE
DB_Table::where('roles', 'object', ["name" => "admin"]);
- INSERT
DB_Table::insert('users', ['fname' => 'Nikko', 'lname' => 'Atuan', 'email' => 'sampleemail@email.com']);
DB_Table::insert('roles', ['name' => 'admin', 'display_name' => 'admin', 'description' => 'admin']);
DB_Table::insert('roles', ['name' => 'superadmin', 'display_name' => 'Super Admin', 'description' => 'Can do all']);
- UPDATE
DB_Table::update('roles', [
"name" => "admin",
"display_name" => "Admin",
"description" => "admin"
], ["id" => 1]);
- DELETE
DB_Table::delete('roles', ["name" => "user", "display_name" => "user"]);
- RESET
DB_Table::reset('roles');