1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-11 08:34:59 +02:00

* new: qualifiy each column name with the table name using DibiResult::setWithTables

* removed DibiResult::setType(TRUE) with autodetection
* removed DibiResult::getFields() & getMetaData() in favour of new method getColumnsMeta()
* MySQLi and MySQL transaction implementation are the same
* better escaping in DibiPostgreDriver (new pg_escape_string and addslashes)
This commit is contained in:
David Grudl
2007-11-30 10:12:45 +00:00
parent 1aad1c8da9
commit cbd37021f2
15 changed files with 313 additions and 353 deletions

View File

@@ -55,26 +55,27 @@ echo '<hr>';
// fetch row by row
foreach ($res as $row => $fields) {
print_r($fields);
foreach ($res as $n => $row) {
print_r($row);
}
echo '<hr>';
// fetch row by row with defined offset
foreach ($res->getIterator(2) as $row => $fields) {
print_r($fields);
foreach ($res->getIterator(2) as $n => $row) {
print_r($row);
}
// fetch row by row with defined offset and limit
foreach ($res->getIterator(2, 1) as $row => $fields) {
print_r($fields);
foreach ($res->getIterator(2, 1) as $n => $row) {
print_r($row);
}
// more complex association array
$res = dibi::query('
SELECT * FROM [products]
SELECT *
FROM [products]
INNER JOIN [orders] USING ([product_id])
INNER JOIN [customers] USING ([customer_id])
');

View File

@@ -13,14 +13,7 @@ dibi::connect(array(
$res = dibi::query('SELECT * FROM [customers]');
// auto-convert this field to integer
// auto-convert this column to integer
$res->setType('customer_id', Dibi::FIELD_INTEGER);
$row = $res->fetch();
var_dump($row);
// auto-detect all types
// WARNING: THIS WILL NOT WORK WITH SQLITE
$res->setType(TRUE);
$row = $res->fetch();
var_dump($row);

View File

@@ -41,7 +41,8 @@ dibi::test("
UPDATE [colors] SET", array(
'color' => 'blue',
'order' => 12,
), "WHERE [id]=%i", 123);
), "
WHERE [id]=%i", 123);
// SELECT
@@ -51,10 +52,15 @@ $timestamp = mktime(0, 0, 0, 10, 13, 1997);
dibi::test('
SELECT COUNT(*) as [count]
FROM [comments]
WHERE [ip] LIKE %s', $ipMask, 'AND [date] > ', dibi::date($timestamp)
WHERE [ip] LIKE %s', $ipMask, '
AND [date] > ', dibi::date($timestamp)
);
// IN array
$array = array(1, 2, 3);
dibi::test("SELECT * FROM [people] WHERE [id] IN (", $array, ")");
dibi::test("
SELECT *
FROM [people]
WHERE [id] IN (", $array, ")
");