forked from MicahCarrick/PHP-MySQL-Database-Class
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
40 lines (30 loc) · 1.06 KB
/
README
File metadata and controls
40 lines (30 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
PHP MySQL Database Class
========================
Copyright (c) 2011 Micah Carrick
All Rights Reserved.
PHP MySQL Database Class is singleton pattern object which serves as a MySQL
database wrapper and an iterator result set object. This project was developed
as a follow up to my older, PHP4 database class from 2004.
Basic Usage
-----------
For a more detailed explanation, consult the phpDocumentor docstrings within
the source code or visit http://www.micahcarrick.com/php5-mysql-database-class.html
Here are some simple examples:
// get the database singleton instance
$db = MySqlDatabase::getInstance();
// connect
try {
$db->connect('localhost', 'username', 'password', 'database_name');
}
catch (Exception $e) {
die($e->getMessage());
}
// iterate a resultset
foreach ($db->iterate("SELECT foo FROM bar LIMIT 10") as $row) {
echo $row->foo;
}
// get just one row
$count = $db->fetchOne("SELECT COUNT(*) FROM foo");
// import from a file (use with caution!)
$num = $db->importSqlFile('test-data.sql');
echo "Imported <strong>$num</strong> statements.<br/>";