Permalink
Browse files

Improve debug output of dsql->debug()

  • Loading branch information...
1 parent 6e7fd9b commit 8e59753a049276ed6984e902c628888c068ba69e @romaninsh romaninsh committed Apr 7, 2011
Showing with 21 additions and 3 deletions.
  1. +21 −3 lib/DBlite/dsql.php
View
@@ -397,7 +397,7 @@ function getArgs($required){
// comma separated fields, such as for select
$fields=array();
if(!is_array($this->args['fields'])){
- $this->fatal('Before generating query you should call $dq->field() several times, otherwise I do not know what fields you need',2);
+ $this->fatal('Before generating query you should call $dq->field() at least once, otherwise I do not know what fields you need',2);
}
foreach($this->args['fields'] as $field) {
$fields[]=$field;
@@ -500,17 +500,35 @@ function parseTemplate($template) {
// now parts array contains strings and array of string, let's request
// for required arguments
+ $dd='';
$args = $this->getArgs($required);
+ $dd.='<ul class="atk-sqldump">';
// now when we know all data, let's assemble resulting string
foreach($result as $key => $part) {
if(is_array($part)) {
$result[$key]=$args[$part[0]];
- }
+
+ $p=$part[0];
+ if($p=='field')$p='fields';
+
+ $a=$this->args[$p];
+ if($a){
+ if(is_array($a)){
+ $dd.="<li><b>".$part[0]."</b> <ul><li>"
+ .join('</li><li>',$a).'</li></ul>';
+ }else{
+ $dd.="<li><b>".$part[0]."</b> $a </li>";
+ }
+ }
+ //}else{
+ //if(trim($part))echo "<font color=blue>$part</font> "; // statement
+ }
}
+ $dd.="</ul>";
if($this->debug){
//$this->db->owner->logVar($result);
- echo '<font color=blue>'.htmlentities(join('',$result)).'</font>';
+ echo '<font color=blue>'.htmlentities(join('',$result)).'</font>'.$dd;
}
return join('', $result);
}

0 comments on commit 8e59753

Please sign in to comment.