Minor changes in storeXMLNode, storeRecord and genXMLNode methods.

This commit is contained in:
tomas 2004-11-08 20:21:15 +00:00
parent 692230835a
commit ad0f796cd1
1 changed files with 19 additions and 13 deletions

View File

@ -23,7 +23,7 @@
Author : $Author: tomas $ Author : $Author: tomas $
Version : $Revision: 1.3 $ Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/MetaData.php,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/MetaData.php,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -217,14 +217,15 @@ class MetaData{
*/ */
function storeXMLNode($node, $parid=NULL, $mode='insert') function storeXMLNode($node, $parid=NULL, $mode='insert')
{ {
//echo $node->node_name().", ".$node->node_type().", ".$node->prefix().", $parid.\n";
switch($node->node_type()){ switch($node->node_type()){
case 1: // element case 1: // element
case 2: // attribute case 2: // attribute
$subjns = (is_null($parid)? '_G' : '_I'); $subjns = (is_null($parid)? '_G' : '_I');
$subject = (is_null($parid)? $this->gunid : $parid); $subject = (is_null($parid)? $this->gunid : $parid);
if(!isset($this->nameSpaces[$node->prefix()])) $prefix = $node->prefix(); $prefix = ($prefix === '' ? '_d' : $prefix);
$this->nameSpaces[$node->prefix()] = $node->namespace_uri(); if(!isset($this->nameSpaces[$prefix]))
$prefix = $node->prefix(); $this->nameSpaces[$prefix] = $node->namespace_uri();
break; break;
} }
switch($node->node_type()){ switch($node->node_type()){
@ -321,16 +322,23 @@ class MetaData{
function storeRecord($subjns, $subject, $predns, $predicate, $predxml='T', function storeRecord($subjns, $subject, $predns, $predicate, $predxml='T',
$objns=NULL, $object=NULL, $mode='insert') $objns=NULL, $object=NULL, $mode='insert')
{ {
//echo "$subjns, $subject, $predns, $predicate, $predxml, $objns, $object, $mode\n";
$predns_sql = (is_null($predns) ? "NULL":"'$predns'" ); $predns_sql = (is_null($predns) ? "NULL":"'$predns'" );
$objns_sql = (is_null($objns) ? "NULL":"'$objns'" ); $objns_sql = (is_null($objns) ? "NULL":"'$objns'" );
$object_sql = (is_null($object)? "NULL":"'$object'"); $object_sql = (is_null($object)? "NULL":"'$object'");
if($mode == 'insert'){ if($mode == 'update'){
$id = $this->dbc->nextId("{$this->mdataTable}_id_seq");
}else{
$cond = "gunid = '{$this->gunid}' AND predns=$predns_sql $cond = "gunid = '{$this->gunid}' AND predns=$predns_sql
AND predicate='$predicate'"; AND predicate='$predicate'";
if($subjns == '_I'){
$cond .= " AND subjns='_I' AND subject='$subject'";
}
$id = $this->dbc->getOne("SELECT id FROM {$this->mdataTable} $id = $this->dbc->getOne("SELECT id FROM {$this->mdataTable}
WHERE $cond"); WHERE $cond");
//echo "$id, ".(is_null($id) ? 'null' : 'not null')."\n";
}
if(is_null($id)){ $mode = 'insert'; }
if($mode == 'insert'){
$id = $this->dbc->nextId("{$this->mdataTable}_id_seq");
} }
if(PEAR::isError($id)) return $id; if(PEAR::isError($id)) return $id;
if($mode == 'insert'){ if($mode == 'insert'){
@ -353,7 +361,7 @@ class MetaData{
objns = $objns_sql, object = $object_sql objns = $objns_sql, object = $object_sql
WHERE id='$id' WHERE id='$id'
"); ");
// WHERE $cond // WHERE $cond
} }
if(PEAR::isError($res)) return $res; if(PEAR::isError($res)) return $res;
return $id; return $id;
@ -408,11 +416,9 @@ class MetaData{
"); ");
if(!is_null($uri) && $uri !== ''){ if(!is_null($uri) && $uri !== ''){
$root =& $domd->document_element(); $root =& $domd->document_element();
# if($row['predns'] !== ''){ if($row['predns'] === '') $row['predns']='_d';
if($row['predns'] === '') $row['predns']='d'; $root->add_namespace($uri, $row['predns']);
$root->add_namespace($uri, $row['predns']); $nxn->set_namespace($uri, $row['predns']);
$nxn->set_namespace($uri, $row['predns']);
# }
} }
if($row['object'] != 'NULL'){ if($row['object'] != 'NULL'){
$tn =& $domd->create_text_node($row['object']); $tn =& $domd->create_text_node($row['object']);