/php-oop-crud

A simple set of functions for carrying out basic CRUD operations in PHP

Primary LanguagePHP

php-oop-crud

CRUD functionlity using PHP's OOP

Edit your database credentials accordingly in the Config class

For insert (Create), one can do:

$params = array(
 'A new post',
 'detachedsoul',
 'This would be the dummy content of this post'
);

$insert = DB::getInstance()->insert('post', ['title', 'author', 'content'], ...$params);

For select (Read), one can do:

 $author = "detachedsoul";

 $select = DB::getInstance()->select('*', 'posts', 'WHERE author = ?', $author);

OR

 $select = DB::getInstance()->select('*', 'posts');

For update (Update), one can do:

 $params = [
  'Title has changed',
  'detachedsoul'
 ];

 $update = DB::getInstance()->update('post', 'title = ?', 'WHERE author = ?', ...$params);

For delete (Delete), one can do:

 $id = 2;

 $delete = DB::getInstance()->delete('post', 'id', $id);