mirror of
https://github.com/dg/dibi.git
synced 2025-08-03 20:57:36 +02:00
examples: added CSS style
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||||
|
|
||||||
<h1>dibi apply limit/offset example</h1>
|
<h1>dibi apply limit/offset example</h1>
|
||||||
<pre>
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debug.php';
|
||||||
@@ -17,14 +19,12 @@ dibi::test('SELECT * FROM [products]');
|
|||||||
// -> SELECT * FROM [products]
|
// -> SELECT * FROM [products]
|
||||||
|
|
||||||
|
|
||||||
echo '<hr>';
|
|
||||||
|
|
||||||
// with limit = 2
|
// with limit = 2
|
||||||
dibi::test('SELECT * FROM [products] %lmt', 2);
|
dibi::test('SELECT * FROM [products] %lmt', 2);
|
||||||
// -> SELECT * FROM [products] LIMIT 2
|
// -> SELECT * FROM [products] LIMIT 2
|
||||||
|
|
||||||
|
|
||||||
echo '<hr>';
|
|
||||||
|
|
||||||
// with limit = 2, offset = 1
|
// with limit = 2, offset = 1
|
||||||
dibi::test('SELECT * FROM [products] %lmt %ofs', 2, 1);
|
dibi::test('SELECT * FROM [products] %lmt %ofs', 2, 1);
|
||||||
|
@@ -1,4 +1,7 @@
|
|||||||
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||||
|
|
||||||
<h1>dibi::connect() example</h1>
|
<h1>dibi::connect() example</h1>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debug.php';
|
||||||
|
47
examples/data/style.css
Normal file
47
examples/data/style.css
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
body {
|
||||||
|
font: 15px/1.5 Tahoma, Verdana, Myriad Web, Syntax, sans-serif;
|
||||||
|
color: #333;
|
||||||
|
background-color: #fff;
|
||||||
|
margin: 1.6em;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2 {
|
||||||
|
font-size: 210%;
|
||||||
|
font-weight: normal;
|
||||||
|
color: #036;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
font-size: 150%;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre.dump {
|
||||||
|
border: 1px solid silver;
|
||||||
|
padding: 1em;
|
||||||
|
margin: 1em 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #000080;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.dump {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
border-collapse:collapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.dump td, table.dump th {
|
||||||
|
color: #505767;
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid #d1cdab;
|
||||||
|
padding: 6px 6px 6px 12px;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.dump th {
|
||||||
|
font-size: 80%;
|
||||||
|
color: #525b37;
|
||||||
|
background: #e3e9ba;
|
||||||
|
}
|
@@ -1,4 +1,7 @@
|
|||||||
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||||
|
|
||||||
<h1>dibi dump example</h1>
|
<h1>dibi dump example</h1>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debug.php';
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||||
|
|
||||||
<h1>dibi extension method example</h1>
|
<h1>dibi extension method example</h1>
|
||||||
<pre>
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debug.php';
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||||
|
|
||||||
<h1>dibi fetch example</h1>
|
<h1>dibi fetch example</h1>
|
||||||
<pre>
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debug.php';
|
||||||
@@ -27,39 +29,33 @@ product_id | title
|
|||||||
// fetch a single row
|
// fetch a single row
|
||||||
$row = dibi::fetch('SELECT title FROM [products]');
|
$row = dibi::fetch('SELECT title FROM [products]');
|
||||||
Debug::dump($row); // Chair
|
Debug::dump($row); // Chair
|
||||||
echo '<hr>';
|
|
||||||
|
|
||||||
|
|
||||||
// fetch a single value
|
// fetch a single value
|
||||||
$value = dibi::fetchSingle('SELECT [title] FROM [products]');
|
$value = dibi::fetchSingle('SELECT [title] FROM [products]');
|
||||||
Debug::dump($value); // Chair
|
Debug::dump($value); // Chair
|
||||||
echo '<hr>';
|
|
||||||
|
|
||||||
|
|
||||||
// fetch complete result set
|
// fetch complete result set
|
||||||
$all = dibi::fetchAll('SELECT * FROM [products]');
|
$all = dibi::fetchAll('SELECT * FROM [products]');
|
||||||
Debug::dump($all);
|
Debug::dump($all);
|
||||||
echo '<hr>';
|
|
||||||
|
|
||||||
|
|
||||||
// fetch complete result set like association array
|
// fetch complete result set like association array
|
||||||
$res = dibi::query('SELECT * FROM [products]');
|
$res = dibi::query('SELECT * FROM [products]');
|
||||||
$assoc = $res->fetchAssoc('title'); // key
|
$assoc = $res->fetchAssoc('title'); // key
|
||||||
Debug::dump($assoc);
|
Debug::dump($assoc);
|
||||||
echo '<hr>';
|
|
||||||
|
|
||||||
|
|
||||||
// fetch complete result set like pairs key => value
|
// fetch complete result set like pairs key => value
|
||||||
$pairs = $res->fetchPairs('product_id', 'title');
|
$pairs = $res->fetchPairs('product_id', 'title');
|
||||||
Debug::dump($pairs);
|
Debug::dump($pairs);
|
||||||
echo '<hr>';
|
|
||||||
|
|
||||||
|
|
||||||
// fetch row by row
|
// fetch row by row
|
||||||
foreach ($res as $n => $row) {
|
foreach ($res as $n => $row) {
|
||||||
Debug::dump($row);
|
Debug::dump($row);
|
||||||
}
|
}
|
||||||
echo '<hr>';
|
|
||||||
|
|
||||||
|
|
||||||
// fetch row by row with defined offset
|
// fetch row by row with defined offset
|
||||||
@@ -83,12 +79,9 @@ INNER JOIN [customers] USING ([customer_id])
|
|||||||
|
|
||||||
$assoc = $res->fetchAssoc('customers.name|products.title'); // key
|
$assoc = $res->fetchAssoc('customers.name|products.title'); // key
|
||||||
Debug::dump($assoc);
|
Debug::dump($assoc);
|
||||||
echo '<hr>';
|
|
||||||
|
|
||||||
$assoc = $res->fetchAssoc('customers.name[]products.title'); // key
|
$assoc = $res->fetchAssoc('customers.name[]products.title'); // key
|
||||||
Debug::dump($assoc);
|
Debug::dump($assoc);
|
||||||
echo '<hr>';
|
|
||||||
|
|
||||||
$assoc = $res->fetchAssoc('customers.name->products.title'); // key
|
$assoc = $res->fetchAssoc('customers.name->products.title'); // key
|
||||||
Debug::dump($assoc);
|
Debug::dump($assoc);
|
||||||
echo '<hr>';
|
|
||||||
|
@@ -1,4 +1,7 @@
|
|||||||
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||||
|
|
||||||
<h1>dibi fluent example</h1>
|
<h1>dibi fluent example</h1>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debug.php';
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||||
|
|
||||||
<h1>dibi import SQL dump example</h1>
|
<h1>dibi import SQL dump example</h1>
|
||||||
<pre>
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debug.php';
|
||||||
|
@@ -1,4 +1,7 @@
|
|||||||
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||||
|
|
||||||
<h1>dibi logger example</h1>
|
<h1>dibi logger example</h1>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debug.php';
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||||
|
|
||||||
<h1>dibi metatypes example</h1>
|
<h1>dibi metatypes example</h1>
|
||||||
<pre>
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debug.php';
|
||||||
|
@@ -1,8 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||||
|
|
||||||
<h1>Nette\Debug & dibi example</h1>
|
<h1>Nette\Debug & dibi example</h1>
|
||||||
|
|
||||||
|
|
||||||
<p>Dibi can display and log exceptions via Nette\Debug, part of Nette Framework.</p>
|
<p>Dibi can display and log exceptions via Nette\Debug, part of Nette Framework.</p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
@@ -1,8 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||||
|
|
||||||
<h1>Nette\Debug & dibi example 2</h1>
|
<h1>Nette\Debug & dibi example 2</h1>
|
||||||
|
|
||||||
|
|
||||||
<p>Dibi can dump variables via Nette\Debug, part of Nette Framework.</p>
|
<p>Dibi can dump variables via Nette\Debug, part of Nette Framework.</p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
@@ -1,3 +1,8 @@
|
|||||||
|
<?php ob_start(1) // needed by FirePHP ?>
|
||||||
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||||
|
|
||||||
|
<h1>Dibi profiler example</h1>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debug.php';
|
||||||
@@ -16,8 +21,6 @@ for ($i=0; $i<20; $i++) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<h1>Dibi profiler example</h1>
|
|
||||||
|
|
||||||
<p>Last query: <strong><?php echo dibi::$sql; ?></strong></p>
|
<p>Last query: <strong><?php echo dibi::$sql; ?></strong></p>
|
||||||
|
|
||||||
<p>Number of queries: <strong><?php echo dibi::$numOfQueries; ?></strong></p>
|
<p>Number of queries: <strong><?php echo dibi::$numOfQueries; ?></strong></p>
|
||||||
|
@@ -1,8 +1,7 @@
|
|||||||
<style>
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||||
pre.dibi { padding-bottom: 10px; }
|
|
||||||
</style>
|
|
||||||
<h1>dibi SQL builder example</h1>
|
<h1>dibi SQL builder example</h1>
|
||||||
<pre>
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debug.php';
|
||||||
|
@@ -1,8 +1,7 @@
|
|||||||
<style>
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||||
pre.dibi { padding-bottom: 10px; }
|
|
||||||
</style>
|
|
||||||
<h1>dibi conditional SQL example</h1>
|
<h1>dibi conditional SQL example</h1>
|
||||||
<pre>
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debug.php';
|
||||||
|
@@ -1,4 +1,7 @@
|
|||||||
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||||
|
|
||||||
<h1>dibi prefix & substitute example</h1>
|
<h1>dibi prefix & substitute example</h1>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debug.php';
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||||
|
|
||||||
<h1>dibi transaction example</h1>
|
<h1>dibi transaction example</h1>
|
||||||
<pre>
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debug.php';
|
||||||
|
Reference in New Issue
Block a user