/crud-mysql-wrapper

Create, Read, Update, Delete wrapper for MySQL. Simple, easy to use class using PDO for simplifing redundant MySQL connections and methods.

Primary LanguagePHP

C.R.U.D. MySQL Wrapper

Create, Read, Update, Delete wrapper for MySQL. Simple, easy to use class using PDO for simplifing redundant MySQL connections and methods.

How To Use

Instantiating the Class

$crud = crud::obtain('localhost', 'databaseUsername', 'databasePassword', 'databaseName');

Reading Table

$result = $crud->query("SELECT * FROM your_table");
print_r($result);

Inserting new data in a table

$data['firstname'] = 'Jack';
$data['lastname'] = 'Jones';
$crud->insert('your_table', $data);

Updating data

$data['firstname'] = 'Joe';
$data['lastname'] = 'Mama';
$crud->update('your_table', $data, 'user_id=4');

Deleting row

$crud->delete('your_table', 'id=123');

Truncate table

Empties all data from the table.

$crud->truncate('your_table');

Drop table

Completely deletes the table.

$crud->drop('your_table');