https://github.com/rs/mydbd
A mysqli OO interface with PEAR::DB API compatibility
https://github.com/rs/mydbd
Last synced: 11 months ago
JSON representation
A mysqli OO interface with PEAR::DB API compatibility
- Host: GitHub
- URL: https://github.com/rs/mydbd
- Owner: rs
- Created: 2009-03-28T21:36:37.000Z (about 17 years ago)
- Default Branch: master
- Last Pushed: 2009-05-03T21:02:56.000Z (about 17 years ago)
- Last Synced: 2025-02-28T06:04:16.750Z (about 1 year ago)
- Language: PHP
- Homepage:
- Size: 109 KB
- Stars: 5
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
MyDBD is a wrapper around mysqli compatible with PEAR::Db and inspired from DBI API. This
is not an abstraction layer meant to handle several type of databases, thus the abstraction
code overhead is very low.
### Example Usage
$dbh = new MyDBD('hostname' => 'localhost'));
$res = $dbh->query('SELECT field1, field2 FROM table WHERE foo = ?', array('bar'));
foreach ($res as $row)
{
printf("field1: %s, field2: %s\n", $row[0], $row[1]);
}
$res->setFetchMode(MyDBD_ResultSet::FETCHMODE_ASSOC);
foreach ($res as $row)
{
printf("field1: %s, field2: %s\n", $row['field1'], $row['field2']);
}
$sth = $dbh->prepare('INSERT INTO table (field1, field2) VALUES(?, ?)');
foreach ($myData as $row)
{
$sth->execute($row[0], $row[1]);
}