Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Wrapper for a PHP MySQL class, which utilizes MySQLi and prepared statements.
Tag: v1.1

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.gitignore
MysqlDb.php
MysqliDb.php
changelog.md
index.php
readme.md

readme.md

To utilize this class, first import Mysqldbi.php into your project, and require it.


require_once('Mysqlidb.php');

After that, create a new instance of the class.


$db = new Mysqlidb('host', 'username', 'password', 'databaseName');

Next, prepare your data, and call the necessary methods.

Insert Query


 'Inserted title',
    'body' => 'Inserted body'
);

if ( $db->insert('posts', $insertData) ) echo 'success!';


Select Query


$results = $db->get('tableName', 'numberOfRows-optional');
print_r($results); // contains array of returned rows

Update Query


$updateData = array(
   'fieldOne' => 'fieldValue',
    'fieldTwo' => 'fieldValue'
);
$db->where('id', int);
$results = $db->update('tableName', $updateData);

Delete Query


$db->where('id', int);
if ( $db->delete('posts') ) echo 'successfully deleted'; 

Generic Query Method


$results = $db->query('SELECT * from posts');
print_r($results); // contains array of returned rows

Where Method

This method allows you to specify the parameters of the query.


$db->where('id', int);
$db->where('title', string);
$results = $db->get('tableName');
print_r($results); // contains array of returned rows

Something went wrong with that request. Please try again.