Skip to content

Commit d671843

Browse files
author
Radovan Janjic
committed
Update README.md
1 parent 80ac832 commit d671843

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,39 @@ $array = $db->fetchQueryToArray('SELECT * FROM `table`');
206206
print_r($array);
207207

208208
// Returns only first row
209-
print_r($db->fetchQueryToArray('SELECT * FROM `table`', TRUE));
209+
$array = $db->fetchQueryToArray('SELECT * FROM `table`', TRUE);
210+
211+
// Print array
212+
print_r($array);
213+
214+
// Close connection
215+
$db->close();
216+
```
217+
218+
*Prepared statements (works only with MySQLi!) - if mysqlnd driver is not installed*
219+
```php
220+
$db = new MySQL_wrapper(MySQL_HOST, MySQL_USER, MySQL_PASS, MySQL_DB);
221+
222+
// Connect
223+
$db->connect();
224+
225+
$stmt = $db->call('prepare', 'SELECT `id`, `firstname`, `surname`, `email` FROM `table` WHERE `level` = ?;');
226+
$stmt->bind_param('i', $level);
227+
$stmt->execute();
228+
229+
$stmt->bind_result($id, $firstname, $surname, $email);
230+
$data = array();
231+
while ($stmt->fetch()) {
232+
$data[] = array(
233+
'id' => $id,
234+
'firstname' => $firstname,
235+
'surname' => $surname,
236+
'email' => $email
237+
);
238+
}
239+
240+
// Print data
241+
print_r($data);
210242

211243
// Close connection
212244
$db->close();

0 commit comments

Comments
 (0)