To utilize this class, first import MysqlDb.php into your project, and require it.
require_once('MysqlDb.php');
After that, create a new instance of the class.
$Db = new MysqlDb('host', 'username', 'password', 'databaseName');
Next, prepare your data, and call the necessary methods.
'Inserted title',
'body' => 'Inserted body'
);
if ( $Db->insert('posts', $insertData) ) echo 'success!';
$results = $Db->get('tableName', 'numberOfRows-optional');
print_r($results); // contains array of returned rows
$updateData = array(
'fieldOne' => 'fieldValue',
'fieldTwo' => 'fieldValue'
);
$Db->where('id', int);
$results = $Db->update('tableName', $updateData);
$Db->where('id', integer);
if ( $Db->delete('posts') ) echo 'successfully deleted';
$results = $Db->query('SELECT * from posts');
print_r($results); // contains array of returned rows
This method allows you to specify the parameters of the query. For now, it only accepts one key => value pair.
$Db->where('id', int);
$results = $Db->get('tableName');
print_r($results); // contains array of returned rows