mirror of
https://github.com/dg/dibi.git
synced 2025-08-05 05:37:39 +02:00
- added DibiDataSource as default implementation of IDataSource
- new modifiers %lmt %ofs - removed old modifier %p (alias for %sql)
This commit is contained in:
34
examples/apply-limit.php
Normal file
34
examples/apply-limit.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<h1>dibi apply limit/offset example</h1>
|
||||
<pre>
|
||||
<?php
|
||||
|
||||
require_once '../dibi/dibi.php';
|
||||
|
||||
|
||||
dibi::connect(array(
|
||||
'driver' => 'sqlite',
|
||||
'database' => 'sample.sdb',
|
||||
));
|
||||
|
||||
|
||||
// no limit
|
||||
$res = dibi::query('SELECT * FROM [products]');
|
||||
foreach ($res as $n => $row) {
|
||||
print_r($row);
|
||||
}
|
||||
|
||||
echo '<hr>';
|
||||
|
||||
// with limit = 2
|
||||
$res = dibi::query('SELECT * FROM [products] %lmt', 2);
|
||||
foreach ($res as $n => $row) {
|
||||
print_r($row);
|
||||
}
|
||||
|
||||
echo '<hr>';
|
||||
|
||||
// with limit = 2, offset = 1
|
||||
$res = dibi::query('SELECT * FROM [products] %lmt %ofs', 2, 1);
|
||||
foreach ($res as $n => $row) {
|
||||
print_r($row);
|
||||
}
|
@@ -15,3 +15,20 @@ ERROR: [1] near "FROM": syntax error
|
||||
-- driver: ;
|
||||
-- 2007-11-15 01:19:00
|
||||
|
||||
OK: SELECT * FROM [customers] WHERE [customer_id] = 1;
|
||||
-- rows: 1
|
||||
-- takes: 0.319 ms
|
||||
-- driver: sqlite
|
||||
-- 2008-01-18 03:57:19
|
||||
|
||||
OK: SELECT * FROM [customers] WHERE [customer_id] < 5;
|
||||
-- rows: 4
|
||||
-- takes: 0.384 ms
|
||||
-- driver: sqlite
|
||||
-- 2008-01-18 03:57:19
|
||||
|
||||
ERROR: [2] sqlite_query(): near "FROM": syntax error
|
||||
-- SQL: SELECT FROM [customers] WHERE [customer_id] < 38
|
||||
-- driver: ;
|
||||
-- 2008-01-18 03:57:19
|
||||
|
||||
|
Reference in New Issue
Block a user