Skip to content

Commit

Permalink
Added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyWay committed Aug 8, 2010
1 parent 4bcdffe commit d52480d
Showing 1 changed file with 65 additions and 1 deletion.
66 changes: 65 additions & 1 deletion readme.md
Expand Up @@ -4,4 +4,68 @@ To utilize this class, first import MysqlDb.php into your project, and require i
<code>
require_once('MysqlDb.php');
</code>
</pre>
</pre>

After that, create a new instance of the class.

<pre>
<code>
$Db = new MysqlDb('host', 'username', 'password', 'databaseName');
</code>
</pre>

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

<h3> Insert Query </h3>
<pre>
<code>
<?php
$insertData = array(
'title' => 'Inserted title',
'body' => 'Inserted body'
);

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

</code>
</pre>

<h3> Select Query </h3>

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

<h3> Update Query </h3>

<pre>
<code>
$updateData = array(
'fieldOne' => 'fieldValue',
'fieldTwo' => 'fieldValue'
);
$Db->where('id', int);
$results = $Db->update('tableName', $updateData);
</code>
</pre>

<h3> Delete Query </h3>

<pre>
<code>
$Db->where('id', integer);
if ( $Db->delete('posts') ) echo 'successfully deleted';
</code>
</pre>

<h3> Generic Query Method </h3>

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

0 comments on commit d52480d

Please sign in to comment.