Skip to content

A Simple Create,Read,Update,Delete Library for your PHP Web App. Basically, there wouldn't be any need to tinker with annoying Query Codes.

Notifications You must be signed in to change notification settings

Kofacts/Simple_CRUD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple_CRUD

A Simple Create,Read,Update,Delete Library for your PHP Web App. Basically, there wouldn't be any need to tinker with annoying Query Codes. Leverages Both MYSQLi and PDO.

How to use?

With Composer

First install Composer using

composer install

Then Require it using

composer require scrud/scrud

Which will then be added to your Composer.json dependencies.

Or

---------------- Using the lib as a Class ------

  1. Clone this Repo which will then be stored in your chosen directory as Simple_CRUD

git clone https://github.com/kofacts/Simple_CRUD.git"

  1. Open the File

  2. Locate the src/ directory and Open the config.php

  3. Fill in the necessary details and DB_Type. MYSQLI or PDO.

$connectDetails=[ "hostname"=>"hostname", "username"=>"username", "password"=>"password", "DB_NAME"=>"database name", "connect_type"=>strtoupper("pdo or mysqli"), ];
  1. Inside your Main Page, say index.php, instantiate a Scrud Object.

$scrud= new Scrud;

  1. Now you Have done the needful, What can you do with all this.

Some of the Basic Methods you can use.

  1. create($tablename,$fields) : The tablename is the name of the Tablename you wish to add Data to, while the fields are the array of data you wish to insert values into. From the code below, the user_details is the tablename, while the array are yes, array of values you wish to insert data into.

$scrud->create("user_details",array("username"=>"Ricesss","password"=>"pico4421ss"));

  1. get($tablename) : params is just $tablename. This would get all fields from DB. Simple instantiate the Scrud Class. eg

$posts=$scrud->get("user_details");

And then loop through all the fields.

foreach($posts as $row) { echo $row['username']; }
  1. get_where($tablename,$id,$value): This would accept params tablename,id/field and the value you wish to get. To use, simply do

$value=$scrud->get_where($tablename,$id,$value) And then use

echo $value['username'];

  1. update($tablename,$field,$id,$value); This would accept params $tablename,$field [arrays],id to be update and value. To use, simply do,

$scrud->update("user_details",array("username"=>"Rapheal","password"=>"skjf..anything"),"id",1);

  1. delete($tablename,$id,$value): This would accept params $tablename,$id to delete and then value. To Use, Simply do,

$scrud->delete("user_details","id",2);

Inspiration

The Concept is inspired by Codeigniter's Sleek Query System. Make it simple, and very simple has always been the name.

Contribute

There are so many features that should be added to this platform. Hey, Don't just leave, you can always contribute by pulling a request.

This would Help Me, How should i thank you.

Nah, Nada, Don't thank Me. Actually, you can thank me by Staring. Em, 😄 I think that is just it.

PS: Some Basic Touches still going on.

Licence

MIT

About

A Simple Create,Read,Update,Delete Library for your PHP Web App. Basically, there wouldn't be any need to tinker with annoying Query Codes.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages