2017 © Pedro Peláez
 

library simplecrud

A Simple CRUD Class to make your development process faster

image

simplecrud/simplecrud

A Simple CRUD Class to make your development process faster

  • Thursday, December 22, 2016
  • by Kofacts
  • Repository
  • 1 Watchers
  • 2 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

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., (*1)

How to use?

With Composer

First install Composer using, (*2)

composer install, (*3)

Then Require it using, (*4)

composer require scrud/scrud, (*5)

Which will then be added to your Composer.json dependencies., (*6)

Or, (*7)

---------------- 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", (*8)

  1. Open the File, (*9)

  2. Locate the src/ directory and Open the config.php, (*10)

  3. Fill in the necessary details and DB_Type. MYSQLI or PDO., (*11)

$connectDetails=[ "hostname"=>"hostname", "username"=>"username", "password"=>"password", "DB_NAME"=>"database name", "connect_type"=>strtoupper("pdo or mysqli"), ]; , (*12)

  1. Inside your Main Page, say index.php, instantiate a Scrud Object.

$scrud= new Scrud;, (*13)

  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")); , (*14)

  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");, (*15)

And then loop through all the fields., (*16)

foreach($posts as $row) { echo $row['username']; } , (*17)

  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, (*18)

echo $value['username'];, (*19)

  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);, (*20)

  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);, (*21)

Inspiration

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

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., (*23)

This would Help Me, How should i thank you.

Nah, Nada, Don't thank Me. Actually, you can thank me by Staring. Em, :smile: I think that is just it., (*24)

PS: Some Basic Touches still going on., (*25)

Licence

MIT, (*26)

The Versions

22/12 2016

dev-master

9999999-dev

A Simple CRUD Class to make your development process faster

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Avatar Kofacts