]> git.nbdom.net Git - nb.git/commitdiff
Bed !
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 7 Mar 2016 04:03:45 +0000 (04:03 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 7 Mar 2016 04:03:45 +0000 (04:03 +0000)
lib/php/db.php
lib/php/db/table.php
lib/php/out.php

index b61bcbe1895f852b19b623c7fb30e01f86ec614f..af9e3a9542126f14e12b14663ad8d046b4df1089 100644 (file)
@@ -509,6 +509,7 @@ EOF;
         array('db.count','Tables count(*)'),
         array('[db.]html_menu','Html menu for tables with links'),
 
+        array('[table.]rows','Dump one table, use format='),
         array('[table.]fields','List fields'),
         array('table.count','Table count(*)'),
         array('table.sql','Get the sql source'),
index b4a14e4c1a1fdeecc0f9fd4b99d2d1c3541cfb6c..0e0fd1b6319107664d54488833ef1b8f38cd6e3c 100644 (file)
@@ -757,15 +757,15 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.
   -----------------------------------------------------------------*/
   function rows_begin_xml() {
     return ''
-      .'<?xml version=“1.0” encoding=“utf-8”?>'.PHP_EOL #<?
+      .'<?xml version="1.0" encoding="utf-8"?>'.PHP_EOL #<?
       #.'<database name="'.$this->db->name.'" table="'.$this->name.'" type="'.$this->db->type.'">'.PHP_EOL
-      .'<table name="'.$this->name.'" database="'.$this->db->name.'" database-type="'.$this->db->type.'">'.PHP_EOL
+      .'<rows name="'.$this->name.'" database="'.$this->db->name.'" database-type="'.$this->db->type.'">'.PHP_EOL
     ;
   }
 
   function rows_rec_xml(&$row) {
     $xml = '';
-    $xml .= "\t<rec>".PHP_EOL;
+    $xml .= "\t<row>".PHP_EOL;
     foreach ($row as $k=>$v) {
       if ($v !== '') $xml .= ''
         . "\t\t<".$k.">"
@@ -773,12 +773,12 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.
         . '</'.$k.'>'
       .PHP_EOL;
     }
-    $xml .= "\t</rec>".PHP_EOL;
+    $xml .= "\t</row>".PHP_EOL;
     return $xml;
   }
 
   function rows_end_xml() {
-    return '</table>'.PHP_EOL;
+    return '</rows>'.PHP_EOL;
   }
 
   /*-----------------------------------------------------------------
@@ -1024,6 +1024,7 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.
 
     } elseif ($action == 'table.rows' or $action == 'rows') {
       #if ($this->p('page')==='0') $this->pset('inc',1);
+      $this->db->print_header($this->p('format'));
       $this->rows(); return true;
 
 # NB 06.03.16     } elseif ($action == 'table') {
index c28c0551d172f62e9062109b56176aa193d4b36a..987a61a4b694af3ec35e4c1ce682035af25f3d03 100644 (file)
@@ -18,6 +18,13 @@ class Out extends Nb {
         'head' => 'out_csv_head',
         'function' => 'out_csv',
       ),
+      'labels' => array(
+        'enclose' => array("<center>".OUT_EOL,"</center>"),
+        'tag_enclose' => 'labels',
+        'tag' => 'label',
+        'function' => 'out_tag',
+        'head' => 'out_tag_head',
+      ),
       'table' => array(
         'enclose' => array("<table>".OUT_EOL,"</table>"),
         'tag_enclose' => 'tr',
@@ -148,7 +155,7 @@ function out_csv_head(&$row,$o) {
 #function out_tag_head(&$row,$o) { return ''; }
 function out_tag_head(&$data,$o) {
   #return var_dump($row,true); return '';
-  $o['tag'] = $o['tag_head'];
+  $o['tag'] = isset($o['tag_head']) ? $o['tag_head'] : $o['tag'];
   $row = out::ar_first($data);
   if (!out::is_hash($row)) $row = $data;
   #if (!is_array($row)) return out_csv(array_fill(0,count($row),'?'));