chregu          Fri Mar 30 02:37:35 2001 EDT

  Modified files:              
    /php4/pear/Experimental/XML sql2xml_ext.php 
  Log:
  a lot of new customizable options.... too much to be listed here, 
  documentation will follow.
  
  
Index: php4/pear/Experimental/XML/sql2xml_ext.php
diff -u php4/pear/Experimental/XML/sql2xml_ext.php:1.2 
php4/pear/Experimental/XML/sql2xml_ext.php:1.3
--- php4/pear/Experimental/XML/sql2xml_ext.php:1.2      Thu Mar 29 13:26:53 2001
+++ php4/pear/Experimental/XML/sql2xml_ext.php  Fri Mar 30 02:37:35 2001
@@ -15,7 +15,7 @@
 // | Authors: Christian Stocker <[EMAIL PROTECTED]>                         |
 // +----------------------------------------------------------------------+
 //
-// $Id: sql2xml_ext.php,v 1.2 2001/03/29 21:26:53 uw Exp $
+// $Id: sql2xml_ext.php,v 1.3 2001/03/30 10:37:35 chregu Exp $
 
 require_once ("XML/sql2xml.php");
 
@@ -41,7 +41,7 @@
  *   for the time being
  *
  * @author   Christian Stocker <[EMAIL PROTECTED]>
- * @version  $Id: sql2xml_ext.php,v 1.2 2001/03/29 21:26:53 uw Exp $
+ * @version  $Id: sql2xml_ext.php,v 1.3 2001/03/30 10:37:35 chregu Exp $
  */
 class XML_sql2xml_ext extends XML_sql2xml {
 
@@ -49,11 +49,12 @@
     function insertNewRow($parent_row, $res, $key, &$tableInfo)
     {
 
-        $new_row = $parent_row->new_child("row", NULL);
+        $new_row= $parent_row->new_child($tableInfo[$key]["table"],Null);
         /* make an unique ID attribute in the row element with tablename.id if 
there's an id
                otherwise just make an unique id with the php-function, just that 
there's a unique id for this row.
                 CAUTION: This ID changes every time ;) (if no id from db-table)
                */
+        $new_row->set_attribute("type","row");
         if ($res[$tableInfo["id"][$tableInfo[$key]["table"]]])
         {
             if ($res[$tableInfo["id"][$tableInfo[$key]["table"]]] == 
$this->user_options[id])
@@ -64,7 +65,9 @@
         }
         else
         {
-            $new_row->set_attribute("ID", uniqid($tableInfo[$key]["table"]));
+            $this->IDcounter[$tableInfo[$key]["table"]]++;
+            $new_row->set_attribute("ID", 
+$tableInfo[$key]["table"].$this->IDcounter[$tableInfo[$key]["table"]]);
+
         }
 
         return $new_row;
@@ -72,21 +75,27 @@
 
 
     function insertNewResult(&$tableInfo) {
-
+        
+        if ($this->user_options["result_root"]) 
+            $result_root = $this->user_options["result_root"];
+        else 
+            $result_root = $tableInfo[0]["table"];
+        
         if ($this->xmlroot)
-            $xmlroot=$this->xmlroot->new_child($tableInfo[0]["table"], NULL);
+            $xmlroot=$this->xmlroot->new_child($result_root,Null);
         else
-            $xmlroot= $this->xmldoc->add_root($tableInfo[0]["table"]);
-    
-        $xmlroot->set_attribute("type", "Database");
-
+            $xmlroot= $this->xmldoc->add_root($result_root);
+        $xmlroot->set_attribute("type","resultset");
         return $xmlroot;
     }
     
 
     function insertNewElement($parent, $res, $key, &$tableInfo, &$subrow) {
 
-        if ($this->user_options["xml_seperator"])
+        if (is_array($this->user_options["attributes"]) && 
+in_array($tableInfo[$key]["name"],$this->user_options["attributes"])) {
+            
+$subrow=$parent->set_attribute($tableInfo[$key]["name"],$this->xml_encode($res[$key]));
+        }
+        elseif ($this->user_options["xml_seperator"])
         {
             //the preg should be only done once....
             $i = 0;
@@ -100,24 +109,23 @@
                     $subrow[$regs[1][$i]] = $subrow[$regs[1][$i - 
1]]->new_child($regs[1][$i], NULL);
                 }
             }
-            $subrows = $subrow[$regs[1][$i - 1]]->new_child($regs[1][$i], 
utf8_encode($res[$key]));
+            $subrows = $subrow[$regs[1][$i - 1]]->new_child($regs[1][$i], 
+$this->xml_encode($res[$key]));
         }
         else
         {
-            $regs[1][0] = $tableInfo[$key]["name"];
-            $i = 0;
-            $subrow=$parent->new_child($regs[1][$i], utf8_encode($res[$key]));
+            $subrow=$parent->new_child($tableInfo[$key]["name"], 
+$this->xml_encode($res[$key]));
         }
 
     }
 
     function addTableinfo($key, $value, &$tableInfo) {
-    
-        if (!$metdata["id"][$value[table]] && $value[name] == 
$this->user_options["element_id"] )
+        if (!$tableInfo[id][$value["table"]] && $value["name"] == 
+$this->user_options["element_id"] )
         {
-            $tableInfo["id"][$value["table"]] = $key;
+            $tableInfo[id][$value["table"]]= $key;
         }
-
+        if ($this->user_options["field_translate"][$value["name"]]) {
+            $tableInfo[$key]["name"] = 
+$this->user_options["field_translate"][$value["name"]];
+        }
     }
 }
 ?>



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to