Commit 5eba6215 authored by Josh Campbell's avatar Josh Campbell

Added Features

parent 8f36a33f
#Mac OS X files
.DS_Store
#Vim leave-behinds
*.swp
\ No newline at end of file
This diff is collapsed.
<h3>Change Log</h3>
<p>Branch off master</p>
<ul>
<li>Changed package name to MySqliDb. This is a MySQLi wrapper.</li>
<li>Added support for multiple dynamicly bound where conditions.</li>
<li>Added state resetting after each query exicution to allow multiple calls to the same connection instance.</li>
<li>Added the ability to staticly retreive the current instance.</li>
<li>Added numRows support to the query method.</li>
<li>The triggered error in _prepareQuery() now also displays the SQL statment and the mysqli error message.</li>
</ul>
\ No newline at end of file
<?php
require_once('MysqlDb.php');
require_once('MysqliDb.php');
$Db = new MysqlDb('localhost', 'root', 'root', 'db');
$insertData = array(
'title' => 'Inserted title',
'body' => 'Inserted body'
);
$results = $Db->insert('posts', $insertData);
print_r($results);
$db = new MysqliDb('localhost', 'root', 'root', 'db');
?>
<!DOCTYPE html>
......@@ -21,6 +12,16 @@ print_r($results);
<title>untitled</title>
</head>
<body>
<?php
$insertData = array(
'title' => 'Inserted title',
'body' => 'Inserted body'
);
$results = $db->insert('posts', $insertData);
print_r($results);
?>
</body>
</html>
\ No newline at end of file
To utilize this class, first import MysqlDb.php into your project, and require it.
To utilize this class, first import Mysqldbi.php into your project, and require it.
<pre>
<code>
require_once('MysqlDb.php');
require_once('Mysqlidb.php');
</code>
</pre>
......@@ -10,7 +10,7 @@ After that, create a new instance of the class.
<pre>
<code>
$Db = new MysqlDb('host', 'username', 'password', 'databaseName');
$db = new Mysqlidb('host', 'username', 'password', 'databaseName');
</code>
</pre>
......@@ -25,7 +25,7 @@ $insertData = array(
'body' => 'Inserted body'
);
if ( $Db->insert('posts', $insertData) ) echo 'success!';
if ( $db->insert('posts', $insertData) ) echo 'success!';
</code>
</pre>
......@@ -34,7 +34,7 @@ if ( $Db->insert('posts', $insertData) ) echo 'success!';
<pre>
<code>
$results = $Db->get('tableName', 'numberOfRows-optional');
$results = $db->get('tableName', 'numberOfRows-optional');
print_r($results); // contains array of returned rows
</code>
</pre>
......@@ -47,8 +47,8 @@ $updateData = array(
'fieldOne' => 'fieldValue',
'fieldTwo' => 'fieldValue'
);
$Db->where('id', int);
$results = $Db->update('tableName', $updateData);
$db->where('id', int);
$results = $db->update('tableName', $updateData);
</code>
</pre>
......@@ -56,8 +56,8 @@ $results = $Db->update('tableName', $updateData);
<pre>
<code>
$Db->where('id', integer);
if ( $Db->delete('posts') ) echo 'successfully deleted';
$db->where('id', int);
if ( $db->delete('posts') ) echo 'successfully deleted';
</code>
</pre>
......@@ -65,17 +65,18 @@ if ( $Db->delete('posts') ) echo 'successfully deleted';
<pre>
<code>
$results = $Db->query('SELECT * from posts');
$results = $db->query('SELECT * from posts');
print_r($results); // contains array of returned rows
</code>
</pre>
<h3> Where Method </h3>
<p>This method allows you to specify the parameters of the query. For now, it only accepts one key => value pair. </p>
<p>This method allows you to specify the parameters of the query.</p>
<pre>
<code>
$Db->where('id', int);
$results = $Db->get('tableName');
$db->where('id', int);
$db->where('title', string);
$results = $db->get('tableName');
print_r($results); // contains array of returned rows
</code>
</pre>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment