Skip to content

Commit 9885438

Browse files
committed
Merge pull request #15 from Xanza/patch-2
Updated syntax, spelling
2 parents 5f443c8 + 407ef86 commit 9885438

File tree

1 file changed

+33
-54
lines changed

1 file changed

+33
-54
lines changed

readme.md

Lines changed: 33 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,90 @@
11
To utilize this class, first import Mysqldbi.php into your project, and require it.
22

3-
<pre>
4-
<code>
3+
```php
54
require_once('Mysqlidb.php');
6-
</code>
7-
</pre>
5+
```
86

97
After that, create a new instance of the class.
108

11-
<pre>
12-
<code>
9+
```php
1310
$db = new Mysqlidb('host', 'username', 'password', 'databaseName');
14-
</code>
15-
</pre>
11+
```
1612

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

19-
<h3> Insert Query </h3>
20-
<pre>
21-
<code>
15+
### Insert Query
2216

17+
```php
2318
$insertData = array(
2419
'title' => 'Inserted title',
2520
'body' => 'Inserted body'
2621
);
2722

28-
if ( $db->insert('posts', $insertData) ) echo 'success!';
23+
if($db->insert('posts', $insertData)) echo 'success!';
24+
```
2925

30-
</code>
31-
</pre>
26+
### Select Query
3227

33-
<h3> Select Query </h3>
34-
35-
<pre>
36-
<code>
28+
```php
3729
$results = $db->get('tableName', 'numberOfRows-optional');
3830
print_r($results); // contains array of returned rows
39-
</code>
40-
</pre>
31+
```
4132

42-
<h3> Update Query </h3>
33+
### Update Query
4334

44-
<pre>
45-
<code>
35+
```php
4636
$updateData = array(
4737
'fieldOne' => 'fieldValue',
4838
'fieldTwo' => 'fieldValue'
4939
);
5040
$db->where('id', int);
5141
$results = $db->update('tableName', $updateData);
52-
</code>
53-
</pre>
42+
```
5443

55-
<h3> Delete Query </h3>
44+
### Delete Query
5645

57-
<pre>
58-
<code>
46+
```php
5947
$db->where('id', int);
60-
if ( $db->delete('posts') ) echo 'successfully deleted';
61-
</code>
62-
</pre>
48+
if($db->delete('posts')) echo 'successfully deleted';
49+
```
6350

64-
<h3> Generic Query Method </h3>
51+
### Generic Query Method
6552

66-
<pre>
67-
<code>
53+
```php
6854
$results = $db->query('SELECT * from posts');
6955
print_r($results); // contains array of returned rows
70-
</code>
71-
</pre>
56+
```
7257

73-
<h3> Raw Query Method </h3>
58+
### Raw Query Method
7459

75-
<pre>
76-
<code>
60+
```php
7761
$params = array(3, 'My Title');
7862
$resutls = $db->rawQuery("SELECT id, title, body FROM posts WHERE id = ? AND tile = ?", $params);
7963
print_r($results); // contains array of returned rows
8064

8165
// will handle any SQL query
8266

8367
$params = array(10, 1, 10, 11, 2, 10);
84-
$resutls = $db->rawQuery("
85-
(SELECT a FROM t1 WHERE a = ? AND B = ? ORDER BY a LIMIT ?)
86-
UNION
87-
(SELECT a FROM t2 WHERE a = ? AND B = ? ORDER BY a LIMIT ?)
88-
", $params);
68+
$resutls = $db->rawQuery("(SELECT a FROM t1 WHERE a = ? AND B = ? ORDER BY a LIMIT ?) UNION(SELECT a FROM t2 WHERE a = ? AND B = ? ORDER BY a LIMIT ?)", $params);
8969
print_r($results); // contains array of returned rows
90-
</code>
91-
</pre>
70+
```
9271

9372

73+
### Where Method
74+
This method allows you to specify the parameters of the query.
9475

95-
<h3> Where Method </h3>
96-
<p>This method allows you to specify the parameters of the query.</p>
97-
<pre>
98-
<code>
76+
```php
9977
$db->where('id', int);
10078
$db->where('title', string);
10179
$results = $db->get('tableName');
10280
print_r($results); // contains array of returned rows
81+
```
82+
83+
Optionally you can use method chaining to call where multiple times without referencing your object over an over:
10384

104-
Optionally you can use method chaining to call where multiple times without referancing your object over an over:
85+
```php
10586
$results = $db
10687
->where('id', 1)
10788
->where('title', 'MyTitle')
10889
->get('tableName');
109-
110-
</code>
111-
</pre>
90+
```

0 commit comments

Comments
 (0)