mirror of
https://github.com/dg/dibi.git
synced 2025-08-01 11:50:15 +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>
|
||||
<pre>
|
||||
|
||||
<?php
|
||||
|
||||
require_once 'Nette/Debug.php';
|
||||
@@ -17,14 +19,12 @@ dibi::test('SELECT * FROM [products]');
|
||||
// -> SELECT * FROM [products]
|
||||
|
||||
|
||||
echo '<hr>';
|
||||
|
||||
// with limit = 2
|
||||
dibi::test('SELECT * FROM [products] %lmt', 2);
|
||||
// -> SELECT * FROM [products] LIMIT 2
|
||||
|
||||
|
||||
echo '<hr>';
|
||||
|
||||
// with limit = 2, offset = 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>
|
||||
|
||||
<?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>
|
||||
|
||||
<?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>
|
||||
<pre>
|
||||
|
||||
<?php
|
||||
|
||||
require_once 'Nette/Debug.php';
|
||||
|
@@ -1,5 +1,7 @@
|
||||
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||
|
||||
<h1>dibi fetch example</h1>
|
||||
<pre>
|
||||
|
||||
<?php
|
||||
|
||||
require_once 'Nette/Debug.php';
|
||||
@@ -27,39 +29,33 @@ product_id | title
|
||||
// fetch a single row
|
||||
$row = dibi::fetch('SELECT title FROM [products]');
|
||||
Debug::dump($row); // Chair
|
||||
echo '<hr>';
|
||||
|
||||
|
||||
// fetch a single value
|
||||
$value = dibi::fetchSingle('SELECT [title] FROM [products]');
|
||||
Debug::dump($value); // Chair
|
||||
echo '<hr>';
|
||||
|
||||
|
||||
// fetch complete result set
|
||||
$all = dibi::fetchAll('SELECT * FROM [products]');
|
||||
Debug::dump($all);
|
||||
echo '<hr>';
|
||||
|
||||
|
||||
// fetch complete result set like association array
|
||||
$res = dibi::query('SELECT * FROM [products]');
|
||||
$assoc = $res->fetchAssoc('title'); // key
|
||||
Debug::dump($assoc);
|
||||
echo '<hr>';
|
||||
|
||||
|
||||
// fetch complete result set like pairs key => value
|
||||
$pairs = $res->fetchPairs('product_id', 'title');
|
||||
Debug::dump($pairs);
|
||||
echo '<hr>';
|
||||
|
||||
|
||||
// fetch row by row
|
||||
foreach ($res as $n => $row) {
|
||||
Debug::dump($row);
|
||||
}
|
||||
echo '<hr>';
|
||||
|
||||
|
||||
// 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
|
||||
Debug::dump($assoc);
|
||||
echo '<hr>';
|
||||
|
||||
$assoc = $res->fetchAssoc('customers.name[]products.title'); // key
|
||||
Debug::dump($assoc);
|
||||
echo '<hr>';
|
||||
|
||||
$assoc = $res->fetchAssoc('customers.name->products.title'); // key
|
||||
Debug::dump($assoc);
|
||||
echo '<hr>';
|
||||
|
@@ -1,4 +1,7 @@
|
||||
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||
|
||||
<h1>dibi fluent example</h1>
|
||||
|
||||
<?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>
|
||||
<pre>
|
||||
|
||||
<?php
|
||||
|
||||
require_once 'Nette/Debug.php';
|
||||
|
@@ -1,4 +1,7 @@
|
||||
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||
|
||||
<h1>dibi logger example</h1>
|
||||
|
||||
<?php
|
||||
|
||||
require_once 'Nette/Debug.php';
|
||||
|
@@ -1,5 +1,7 @@
|
||||
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||
|
||||
<h1>dibi metatypes example</h1>
|
||||
<pre>
|
||||
|
||||
<?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>
|
||||
|
||||
|
||||
<p>Dibi can display and log exceptions via Nette\Debug, part of Nette Framework.</p>
|
||||
|
||||
<ul>
|
||||
|
@@ -1,8 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||
|
||||
<h1>Nette\Debug & dibi example 2</h1>
|
||||
|
||||
|
||||
<p>Dibi can dump variables via Nette\Debug, part of Nette Framework.</p>
|
||||
|
||||
<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
|
||||
|
||||
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>Number of queries: <strong><?php echo dibi::$numOfQueries; ?></strong></p>
|
||||
|
@@ -1,8 +1,7 @@
|
||||
<style>
|
||||
pre.dibi { padding-bottom: 10px; }
|
||||
</style>
|
||||
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||
|
||||
<h1>dibi SQL builder example</h1>
|
||||
<pre>
|
||||
|
||||
<?php
|
||||
|
||||
require_once 'Nette/Debug.php';
|
||||
|
@@ -1,8 +1,7 @@
|
||||
<style>
|
||||
pre.dibi { padding-bottom: 10px; }
|
||||
</style>
|
||||
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||
|
||||
<h1>dibi conditional SQL example</h1>
|
||||
<pre>
|
||||
|
||||
<?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>
|
||||
|
||||
<?php
|
||||
|
||||
require_once 'Nette/Debug.php';
|
||||
|
@@ -1,5 +1,7 @@
|
||||
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||
|
||||
<h1>dibi transaction example</h1>
|
||||
<pre>
|
||||
|
||||
<?php
|
||||
|
||||
require_once 'Nette/Debug.php';
|
||||
|
Reference in New Issue
Block a user