From 8d063fe0a19aae4a3a9929fad49a44e31076952c Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 28 Oct 2008 19:31:32 +0000 Subject: [PATCH] - added DibiPostgreDriver::getIndexes() - implemented DibiTables types autodetection - all examples uses Nette::Debug --- dibi/drivers/postgre.php | 43 ++- dibi/libs/DibiTable.php | 9 +- examples/Nette/Debug.php | 609 ++++++++++++++++++++++++++++++++++ examples/Nette/license.txt | 62 ++++ examples/Nette/readme.txt | 3 + examples/apply-limit.php | 1 + examples/connect.php | 1 + examples/datetime.demo.php | 1 + examples/dibi.table.php | 13 +- examples/dump.php | 1 + examples/extension.method.php | 3 +- examples/fetch.php | 23 +- examples/fluent.test.php | 1 + examples/load-sql-dump.php | 1 + examples/logger.php | 1 + examples/metatypes.php | 3 +- examples/nette-debug.php | 2 +- examples/profiler.php | 3 +- examples/sql-builder.php | 1 + examples/sql-condition.php | 1 + examples/table-prefix.php | 1 + examples/transaction.php | 1 + 22 files changed, 758 insertions(+), 26 deletions(-) create mode 100644 examples/Nette/Debug.php create mode 100644 examples/Nette/license.txt create mode 100644 examples/Nette/readme.txt diff --git a/dibi/drivers/postgre.php b/dibi/drivers/postgre.php index 8a13cd37..ef4e31bb 100644 --- a/dibi/drivers/postgre.php +++ b/dibi/drivers/postgre.php @@ -409,6 +409,11 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver */ public function getTables() { + $version = pg_version($this->connection); + if ($version['server'] < 8) { + throw new NotSupportedException('Reflection requires PostgreSQL 8.'); + } + $this->query(" SELECT table_name as name, CAST(table_type = 'VIEW' AS INTEGER) as view FROM information_schema.tables @@ -431,8 +436,9 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver $_table = $this->escape($table, dibi::FIELD_TEXT); $this->query(" SELECT indkey - FROM pg_index, pg_class - WHERE pg_class.relname = $_table AND pg_class.oid = pg_index.indrelid AND pg_index.indisprimary + FROM pg_class + LEFT JOIN pg_index on pg_class.oid = pg_index.indrelid AND pg_index.indisprimary + WHERE pg_class.relname = $_table "); $primary = (int) pg_fetch_object($this->resultSet)->indkey; @@ -469,7 +475,38 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver */ public function getIndexes($table) { - throw new NotImplementedException; + $_table = $this->escape($table, dibi::FIELD_TEXT); + $this->query(" + SELECT ordinal_position, column_name + FROM information_schema.columns + WHERE table_name = $_table AND table_schema = current_schema() + ORDER BY ordinal_position + "); + + $columns = array(); + while ($row = $this->fetch(TRUE)) { + $columns[$row['ordinal_position']] = $row['column_name']; + } + + $this->query(" + SELECT pg_class2.relname, indisunique, indisprimary, indkey + FROM pg_class + LEFT JOIN pg_index on pg_class.oid = pg_index.indrelid + INNER JOIN pg_class as pg_class2 on pg_class2.oid = pg_index.indexrelid + WHERE pg_class.relname = $_table + "); + + $res = array(); + while ($row = $this->fetch(TRUE)) { + $res[$row['relname']]['name'] = $row['relname']; + $res[$row['relname']]['unique'] = $row['indisunique'] === 't'; + $res[$row['relname']]['primary'] = $row['indisprimary'] === 't'; + foreach (explode(' ', $row['indkey']) as $index) { + $res[$row['relname']]['columns'][] = $columns[$index]; + } + } + $this->free(); + return array_values($res); } diff --git a/dibi/libs/DibiTable.php b/dibi/libs/DibiTable.php index d624c914..f03f865b 100644 --- a/dibi/libs/DibiTable.php +++ b/dibi/libs/DibiTable.php @@ -52,7 +52,7 @@ abstract class DibiTable extends DibiObject /** @var array */ protected $blankRow = array(); - /** @var array of pairs [type, format] */ + /** @var mixed; TRUE means autodetect, or array of pairs [type, format] */ protected $types = array(); @@ -325,7 +325,12 @@ abstract class DibiTable extends DibiObject */ protected function complete($res) { - $res->setTypes($this->types); + if (is_array($this->types)) { + $res->setTypes($this->types); + + } elseif ($this->types === TRUE) { + $res->detectTypes(); + } return $res; } diff --git a/examples/Nette/Debug.php b/examples/Nette/Debug.php new file mode 100644 index 00000000..e704468b --- /dev/null +++ b/examples/Nette/Debug.php @@ -0,0 +1,609 @@ +file=$file;$this->line=$line;$this->context=$context;}}final +class +Framework{const +VERSION='0.8';const +REVISION='106 released on 2008/10/27 11:13:57';final +public +function +__construct(){throw +new +LogicException("Cannot instantiate static class ".get_class($this));}public +static +function +compareVersion($version){return +version_compare($version,self::VERSION);}public +static +function +promo($xhtml=TRUE){echo'Powered by Nette Framework':'>'),'';}}final +class +Debug{public +static$counters=array();public +static$html;public +static$maxDepth=3;public +static$maxLen=150;private +static$enabled=FALSE;public +static$useFirebug;private +static$logFile;private +static$logHandle;private +static$sendEmails;private +static$emailHeaders=array('To'=>'','From'=>'noreply@%host%','X-Mailer'=>'Nette Framework','Subject'=>'PHP: An error occurred on the server %host%','Body'=>'[%date%]');public +static$mailer=array(__CLASS__,'sendEmail');public +static$emailProbability=0.01;public +static$keysToHide=array('password','passwd','pass','pwd','creditcard','credit card','cc','pin');private +static$colophons=array(array(__CLASS__,'getDefaultColophons'));private +static$keyFilter=array();public +static$time;private +static$fireCounter;const +LOG='LOG';const +INFO='INFO';const +WARN='WARN';const +ERROR='ERROR';final +public +function +__construct(){throw +new +LogicException("Cannot instantiate static class ".get_class($this));}public +static +function +dump($var,$return=FALSE){self::$keyFilter=FALSE;$output="
".self::_dump($var,0)."
\n";if(!self::$html){$output=htmlspecialchars_decode(strip_tags($output),ENT_NOQUOTES);}if($return){return$output;}else{echo$output;return$var;}}private +static +function +_dump(&$var,$level){if(is_bool($var)){return"bool(".($var?'TRUE':'FALSE').")\n";}elseif($var===NULL){return"NULL\n";}elseif(is_int($var)){return"int($var)\n";}elseif(is_float($var)){return"float($var)\n";}elseif(is_string($var)){if(self::$maxLen&&strlen($var)>self::$maxLen){$s=htmlSpecialChars(substr($var,0,self::$maxLen),ENT_NOQUOTES).' ... ';}else{$s=htmlSpecialChars($var,ENT_NOQUOTES);}return"string(".strlen($var).") \"$s\"\n";}elseif(is_array($var)){$s="array(".count($var).") {\n";$space=str_repeat(' ',$level);static$marker;if($marker===NULL)$marker=uniqid("\x00",TRUE);if(isset($var[$marker])){$s.="$space *RECURSION*\n";}elseif($level&$v){if($k===$marker)continue;$s.="$space ".(is_int($k)?$k:"\"$k\"")." => ";if(self::$keyFilter&&is_string($v)&&isset(self::$keyFilter[strtolower($k)])){$s.="string(?) *** hidden ***\n";}else{$s.=self::_dump($v,$level+1);}}unset($var[$marker]);}else{$s.="$space ...\n";}return$s."$space}\n";}elseif(is_object($var)){$arr=(array)$var;$s="object(".get_class($var).") (".count($arr).") {\n";$space=str_repeat(' ',$level);static$list=array();if(in_array($var,$list,TRUE)){$s.="$space *RECURSION*\n";}elseif($level&$v){$m='';if($k[0]==="\x00"){$m=$k[1]==='*'?' protected':' private';$k=substr($k,strrpos($k,"\x00")+1);}$s.="$space \"$k\"$m => ";if(self::$keyFilter&&is_string($v)&&isset(self::$keyFilter[strtolower($k)])){$s.="string(?) *** hidden ***\n";}else{$s.=self::_dump($v,$level+1);}}array_pop($list);}else{$s.="$space ...\n";}return$s."$space}\n";}elseif(is_resource($var)){return"resource of type(".get_resource_type($var).")\n";}else{return"unknown type\n";}}public +static +function +timer(){static$time=0;$now=microtime(TRUE);$delta=$now-$time;$time=$now;return$delta;}public +static +function +enable($level=E_ALL,$logErrors=NULL,$sendEmails=FALSE){if(version_compare(PHP_VERSION,'5.2.1')===0){throw +new +NotSupportedException(__METHOD__.' is not supported in PHP 5.2.1');}if($logErrors===NULL&&class_exists('Environment')){$logErrors=Environment::isLive();}if(self::$useFirebug===NULL){self::$useFirebug=function_exists('json_encode')&&!$logErrors&&isset($_SERVER['HTTP_USER_AGENT'])&&strpos($_SERVER['HTTP_USER_AGENT'],'FirePHP/');}if($level!==NULL){error_reporting($level);}if(function_exists('ini_set')){ini_set('display_startup_errors',!$logErrors);ini_set('display_errors',!$logErrors);ini_set('html_errors',self::$html);ini_set('log_errors',(bool)$logErrors);}elseif($logErrors){throw +new +NotSupportedException('Function ini_set() is not enabled.');}if($logErrors){if(is_string($logErrors)){self::$logFile=strpos($logErrors,'%')===FALSE?$logErrors:Environment::expand($logErrors);}else{try{self::$logFile=Environment::expand('%logDir%/php_error.log');}catch(InvalidStateException$e){self::$logFile='php_error.log';}}ini_set('error_log',self::$logFile);}self::$sendEmails=$logErrors&&$sendEmails;if(self::$sendEmails){if(is_string($sendEmails)){self::$emailHeaders['To']=$sendEmails;}elseif(is_array($sendEmails)){self::$emailHeaders=$sendEmails+self::$emailHeaders;}if(mt_rand()/mt_getrandmax()1,E_CORE_ERROR=>1,E_COMPILE_ERROR=>1,E_USER_ERROR=>1,E_PARSE=>1,E_RECOVERABLE_ERROR=>1);if(isset($fatals[$severity])){throw +new +FatalErrorException($message,0,$severity,$file,$line,$context);}elseif(($severity&error_reporting())!==$severity){return +NULL;}elseif(self::$useFirebug&&!headers_sent()){$types=array(E_WARNING=>'Warning',E_USER_WARNING=>'Warning',E_NOTICE=>'Notice',E_USER_NOTICE=>'Notice',E_STRICT=>'Strict standards',E_DEPRECATED=>'Deprecated');$type=isset($types[$severity])?$types[$severity]:'Unknown error';$message=strip_tags($message);self::fireLog("$type: $message in $file on line $line",'WARN');return +NULL;}return +FALSE;}public +static +function +paintBlueScreen(Exception$exception){$colophons=self::$colophons;function +_netteDebugPrintCode($file,$line,$count=15){if(function_exists('ini_set')){ini_set('highlight.comment','#999; font-style: italic');ini_set('highlight.default','#000');ini_set('highlight.html','#06b');ini_set('highlight.keyword','#d24; font-weight: bold');ini_set('highlight.string','#080');}$start=max(1,$line-floor($count/2));$source=explode("\n",@highlight_file($file,TRUE));echo$source[0];$source=explode('
',$source[1]);array_unshift($source,NULL);$i=$start;while(--$i>=1){if(preg_match('#.*(]*>)#',$source[$i],$m)){if($m[1]!=='')echo$m[1];break;}}$source=array_slice($source,$start,$count,TRUE);end($source);$numWidth=strlen((string)key($source));foreach($source +as$n=>$s){$s=str_replace(array("\r","\n"),array('',''),$s);if($n===$line){printf("Line %{$numWidth}s: %s\n%s",$n,strip_tags($s),preg_replace('#[^>]*(<[^>]+>)[^<]*#','$1',$s));}else{printf("Line %{$numWidth}s: %s\n",$n,$s);}}echo'';}function +_netteOpenPanel($name,$collaped){static$id;$id++;?> +
+

+ +
+ +
+
+ ';}?> + + + + + + + <?php echo +htmlspecialchars(get_class($exception))?> + + + + + + + + + + +
+

getCode()?' #'.$exception->getCode():'')?>

+ +

getMessage())?>

+
+ + + + + + + + +
+

getCode()?' #'.$ex->getCode():'')?>

+ +

getMessage())?>

+
+ + + getFile())):?> + +

File: getFile())?>   Line: getLine()?>

+
getFile(),$ex->getLine())?>
+ + + + + + +
    + getTrace()as$key=>$row):?> +
  1. + + + ',htmlSpecialChars(basename($row['file'])),' (',$row['line'],')'?> + + <PHP inner-code> + + + ')">source   + + + + + (')">arguments ) +

    + + + + + + + + + + +
  2. + +
+ + + + + + getPanels()as$name=>$panel):?> + + + + + + + + + context)&&is_array($ex->context)):?> + + + context +as$k=>$v){echo'\n";}?> +
$',htmlspecialchars($k),'',self::safeDump($v,$k),"
+ + + + getPrevious())||(isset($ex->previous)&&$ex=$ex->previous));?> + + + + + + + + +

Constants

+ + $v){echo'\n";}?> +
',htmlspecialchars($k),'',self::safeDump($v,$k),"
+ + + +

Included files ()

+ + \n";}?> + + + +

$_SERVER

+ +

empty

+ + + $v)echo'\n";?> +
',htmlspecialchars($k),'',self::dump($v,TRUE),"
+ + + + + + + + +

Headers

+ + $v)echo'\n";?> +
',htmlspecialchars($k),'',htmlspecialchars($v),"
+ + + + +

$

+ +

empty

+ + + $v)echo'\n";?> +
',htmlspecialchars($k),'',self::dump($v,TRUE),"
+ + + + + + + +

Headers

+ +
';?>
+ +

no headers

+ + + + +
    + +
  • + +
+ + +$value){$header.="$key: $value\r\n";}$body=str_replace("\r\n","\n",$body);if(PHP_OS!='Linux')$body=str_replace("\n","\r\n",$body);if($to==='debug'){self::dump(array($to,$subject,$body,$header));}else{mail($to,$subject,$body,$header);}}private +static +function +safeDump($var,$key=NULL){self::$keyFilter=array_change_key_case(array_flip(self::$keysToHide),CASE_LOWER);if($key!==NULL&&isset(self::$keyFilter[strtolower($key)])){return'*** hidden ***';}return"
".self::_dump($var,0)."
\n";}public +static +function +enableProfiler(){register_shutdown_function(array(__CLASS__,'paintProfiler'));}public +static +function +paintProfiler(){$colophons=self::$colophons;if(self::$useFirebug){foreach(self::$colophons +as$callback){foreach((array)call_user_func($callback,'profiler')as$line)self::fireLog(strip_tags($line));}}if(!isset($_SERVER['HTTP_X_REQUESTED_WITH'])||$_SERVER['HTTP_X_REQUESTED_WITH']!=='XMLHttpRequest'){?> + + + + + +
+
    + +
  • + +
+
+ + + +$value){if(is_array($value))$value=implode(', ',$value);$arr[]=htmlSpecialChars($name).' = '.htmlSpecialChars($value).'';}$autoloaded=class_exists('AutoLoader',FALSE)?AutoLoader::$count:0;$s=''.count(get_included_files()).'/'.$autoloaded.' files, ';$exclude=array('stdClass','Exception','ErrorException','Traversable','IteratorAggregate','Iterator','ArrayAccess','Serializable','Closure');foreach(get_loaded_extensions()as$ext){$ref=new +ReflectionExtension($ext);$exclude=array_merge($exclude,$ref->getClassNames());}$classes=array_diff(get_declared_classes(),$exclude);$intf=array_diff(get_declared_interfaces(),$exclude);$func=get_defined_functions();$func=(array)@$func['user'];$consts=get_defined_constants(TRUE);$consts=array_keys((array)@$consts['user']);foreach(array('classes','intf','func','consts')as$item){$s.=''.count($$item).' '.$item.', ';}$arr[]=$s;}if($sender==='bluescreen'){$arr[]='PHP '.PHP_VERSION;if(isset($_SERVER['SERVER_SOFTWARE']))$arr[]=htmlSpecialChars($_SERVER['SERVER_SOFTWARE']);$arr[]='Nette Framework '.Framework::VERSION.' (revision '.Framework::REVISION.')';$arr[]='Report generated at '.@strftime('%c',Debug::$time);}return$arr;}public +static +function +fireDump($var,$key){return +self::fireSend(2,array((string)$key=>$var));}public +static +function +fireLog($message,$priority=self::LOG,$label=NULL){if($message +instanceof +Exception){$priority='TRACE';$message=array('Class'=>get_class($message),'Message'=>$message->getMessage(),'File'=>$message->getFile(),'Line'=>$message->getLine(),'Trace'=>self::replaceObjects($message->getTrace()));}elseif($priority==='GROUP_START'){$label=$message;$message=NULL;}return +self::fireSend(1,array(array('Type'=>$priority,'Label'=>$label),$message));}private +static +function +fireSend($index,$payload){if(headers_sent())return +FALSE;if(!self::$fireCounter){header('X-Wf-Protocol-nette: http://meta.wildfirehq.org/Protocol/JsonStream/0.2');header('X-Wf-nette-Plugin-1: http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.2.0');header('X-Wf-nette-Structure-1: http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1');header('X-Wf-nette-Structure-2: http://meta.firephp.org/Wildfire/Structure/FirePHP/Dump/0.1');}$payload=json_encode($payload);foreach(str_split($payload,4990)as$s){$num=++self::$fireCounter;header("X-Wf-nette-$index-1-$num: |$s|\\");}header("X-Wf-nette-$index-1-$num: |$s|");header("X-Wf-nette-Index: $num");return +TRUE;}static +private +function +replaceObjects($val){foreach($val +as$k=>$v){if(is_object($v)){$val[$k]='object '.get_class($v).'';}elseif(is_array($v)){$val[$k]=self::replaceObjects($v);}}return$val;}}Debug::$html=PHP_SAPI!=='cli';Debug::$time=microtime(TRUE); \ No newline at end of file diff --git a/examples/Nette/license.txt b/examples/Nette/license.txt new file mode 100644 index 00000000..b2ef3165 --- /dev/null +++ b/examples/Nette/license.txt @@ -0,0 +1,62 @@ +The Nette License, Version 1 +============================ + +Copyright (c) 2004, 2008 David Grudl (http://davidgrudl.com) +All rights reserved. + +This license is a legal agreement between you and David Grudl (the "Author") +for the use of Nette Framework (the "Software"). By obtaining, using and/or +copying the Software, you agree that you have read, understood, and will +comply with the terms and conditions of this license. + + +PERMITTED USE +------------- + +You are permitted to use, copy, modify, and distribute the Software and its +documentation, with or without modification, for any purpose, provided that +the following conditions are met: + +1. A copy of this license agreement must be included with the distribution. + +2. Redistributions of source code must retain the above copyright notice in + all source code files. + +3. Redistributions in binary form must reproduce the above copyright notice + in the documentation and/or other materials provided with the distribution. + +4. Products derived from the Software must include an acknowledgment that + they are derived from Nette Framework in their documentation and/or other + materials provided with the distribution. + +5. The name "Nette Framework" must not be used to endorse or promote products + derived from the Software without prior written permission from Author. + +6. Products derived from the Software may not be called "Nette Framework", + nor may "Nette" appear in their name, without prior written + permission from Author. + + +INDEMNITY +--------- + +You agree to indemnify and hold harmless the Author and any contributors +for any direct, indirect, incidental, or consequential third-party claims, +actions or suits, as well as any related expenses, liabilities, damages, +settlements or fees arising from your use or misuse of the Software, +or a violation of any terms of this license. + + +DISCLAIMER OF WARRANTY +---------------------- + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/examples/Nette/readme.txt b/examples/Nette/readme.txt new file mode 100644 index 00000000..6d2c3090 --- /dev/null +++ b/examples/Nette/readme.txt @@ -0,0 +1,3 @@ +This file is part of Nette Framework + +For more information please see http://nettephp.com diff --git a/examples/apply-limit.php b/examples/apply-limit.php index 60b0d3f5..804bdb57 100644 --- a/examples/apply-limit.php +++ b/examples/apply-limit.php @@ -2,6 +2,7 @@
 dibi::connect() example
 IDibiVariable example
 
 primary\n";
 
 // Finds rows by primary key
 foreach ($products->find(1, 3) as $row) {
-	print_r($row);
+	Debug::dump($row);
 }
 
 
@@ -61,26 +62,26 @@ $count = $products->delete(1);
 
 // deletes multiple rows
 $count = $products->delete(array(1, 2, 3));
-var_dump($count); // number of deleted rows
+Debug::dump($count); // number of deleted rows
 
 
 // update row #2 in a table
 $data = (object) NULL;
 $data->title = 'New title';
 $count = $products->update(2, $data);
-var_dump($count); // number of updated rows
+Debug::dump($count); // number of updated rows
 
 
 // update multiple rows in a table
 $count = $products->update(array(3, 5), $data);
-var_dump($count); // number of updated rows
+Debug::dump($count); // number of updated rows
 
 
 // inserts row into a table
 $data = array();
 $data['title'] = 'New product';
 $id = $products->insert($data);
-var_dump($id); // generated id
+Debug::dump($id); // generated id
 
 
 // inserts or updates row into a table
@@ -97,4 +98,4 @@ $products->delete($key);
 
 
 // select all using fluent interface
-var_dump($products->select('*')->orderBy('title')->fetchAll());
+Debug::dump($products->select('*')->orderBy('title')->fetchAll());
diff --git a/examples/dump.php b/examples/dump.php
index 8e06ee0e..d3a9a6a9 100644
--- a/examples/dump.php
+++ b/examples/dump.php
@@ -1,6 +1,7 @@
 

dibi dump example

fetchShuffle(); -print_r($all); +Debug::dump($all); diff --git a/examples/fetch.php b/examples/fetch.php index dd7a5150..6c67de55 100644 --- a/examples/fetch.php +++ b/examples/fetch.php @@ -2,6 +2,7 @@
 ';
 
 
 // fetch a single value
 $value = dibi::fetchSingle('SELECT [title] FROM [products]');
-print_r($value); // Chair
+Debug::dump($value); // Chair
 echo '
'; // fetch complete result set $all = dibi::fetchAll('SELECT * FROM [products]'); -print_r($all); +Debug::dump($all); echo '
'; // fetch complete result set like association array $res = dibi::query('SELECT * FROM [products]'); $assoc = $res->fetchAssoc('title'); // key -print_r($assoc); +Debug::dump($assoc); echo '
'; // fetch complete result set like pairs key => value $pairs = $res->fetchPairs('product_id', 'title'); -print_r($pairs); +Debug::dump($pairs); echo '
'; // fetch row by row foreach ($res as $n => $row) { - print_r($row); + Debug::dump($row); } echo '
'; // fetch row by row with defined offset foreach ($res->getIterator(2) as $n => $row) { - print_r($row); + Debug::dump($row); } // fetch row by row with defined offset and limit foreach ($res->getIterator(2, 1) as $n => $row) { - print_r($row); + Debug::dump($row); } @@ -81,13 +82,13 @@ INNER JOIN [customers] USING ([customer_id]) '); $assoc = $res->fetchAssoc('customers.name,products.title'); // key -print_r($assoc); +Debug::dump($assoc); echo '
'; $assoc = $res->fetchAssoc('customers.name,#,products.title'); // key -print_r($assoc); +Debug::dump($assoc); echo '
'; $assoc = $res->fetchAssoc('customers.name,=,products.title'); // key -print_r($assoc); +Debug::dump($assoc); echo '
'; diff --git a/examples/fluent.test.php b/examples/fluent.test.php index c7aad120..9aa4b7c4 100644 --- a/examples/fluent.test.php +++ b/examples/fluent.test.php @@ -1,6 +1,7 @@

dibi dump example

dibi logger example setType('customer_id', Dibi::FIELD_INTEGER); $res->setType('added', Dibi::FIELD_DATETIME, 'H:i j.n.Y'); $row = $res->fetch(); -var_dump($row); +Debug::dump($row); // outputs: // object(DibiRow)#3 (3) { // customer_id => int(1) diff --git a/examples/nette-debug.php b/examples/nette-debug.php index 4767df9c..f93c568e 100644 --- a/examples/nette-debug.php +++ b/examples/nette-debug.php @@ -1,7 +1,7 @@

Nette::Debug & dibi example

-

Dibi can display and log exceptions via Nette::Debug. You first need to install Nette Framework. You can download it from here:

+

Dibi can display and log exceptions via Nette::Debug, part of Nette Framework.

  • Nette Framework: http://nettephp.com diff --git a/examples/profiler.php b/examples/profiler.php index 5804826e..c14fe038 100644 --- a/examples/profiler.php +++ b/examples/profiler.php @@ -1,6 +1,6 @@ -

    Dibi profiler example

    +

    Dibi profiler example

    Last query:

    diff --git a/examples/sql-builder.php b/examples/sql-builder.php index 739fa01a..7b286e2d 100644 --- a/examples/sql-builder.php +++ b/examples/sql-builder.php @@ -5,6 +5,7 @@ pre.dibi { padding-bottom: 10px; }
     
     dibi prefix & substitute example