Skip to content

A PHP Classes for Database and Table helper methods and CRUD.

Notifications You must be signed in to change notification settings

ErxrilOwl/PHP-DB_Table

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

PHP-DB_Table

A PHP Classes for Database and Table helper methods and CRUD.

Using Database Class

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

Using DB_Table Class

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

About

A PHP Classes for Database and Table helper methods and CRUD.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages