fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [6987] property BIM: coping with db-slashes


From: Sigurd Nes
Subject: [Fmsystem-commits] [6987] property BIM: coping with db-slashes
Date: Tue, 15 Feb 2011 17:13:49 +0000

Revision: 6987
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=6987
Author:   sigurdne
Date:     2011-02-15 17:13:48 +0000 (Tue, 15 Feb 2011)
Log Message:
-----------
property BIM: coping with db-slashes

Modified Paths:
--------------
    branches/dev-bim2/property/inc/class.sobimitem.inc.php

Modified: branches/dev-bim2/property/inc/class.sobimitem.inc.php
===================================================================
--- branches/dev-bim2/property/inc/class.sobimitem.inc.php      2011-02-15 
17:13:12 UTC (rev 6986)
+++ branches/dev-bim2/property/inc/class.sobimitem.inc.php      2011-02-15 
17:13:48 UTC (rev 6987)
@@ -46,7 +46,7 @@
                $this->db->query($sql);
                while($this->db->next_record())
                {
-                       $bimItem = new 
BimItem($this->db->f('id'),$this->db->f('guid'), $this->db->f('type'), 
$this->db->f('xml_representation'));
+                       $bimItem = new 
BimItem($this->db->f('id'),$this->db->f('guid'), $this->db->f('type'), 
$this->db->f('xml_representation',true));
                        array_push($bimItemArray, $bimItem);
                }
 
@@ -66,16 +66,20 @@
                        throw new Exception('Item not found!');
                } else {
                        $this->db->next_record();
-                       return new 
BimItem($this->db->f('id'),$this->db->f('guid'), $this->db->f('type'), 
$this->db->f('xml_representation'),$this->db->f('model'));
+                       return new 
BimItem($this->db->f('id'),$this->db->f('guid'), $this->db->f('type'), 
$this->db->f('xml_representation',true),$this->db->f('model'));
                }
        }
        
        public function addBimItem($bimItem) {
                /* @var $bimItem BimItem */
+               if(!$bimItem->getModelId())
+               {
+                       throw new Exception('ModelId not set');
+               }
                
                $sql = "INSERT INTO ".self::bimItemTable." (type, guid, 
xml_representation, model) values (";
                $sql = $sql."(select id from ".self::bimTypeTable." where name 
= '".$bimItem->getType()."'),";
-               $sql = $sql."'".$bimItem->getGuid()."', 
'".$bimItem->getXml()."', ".$bimItem->getModelId().")";
+               $sql = $sql."'".$bimItem->getGuid()."', 
'".$this->db->db_addslashes($bimItem->getXml())."', 
".$bimItem->getModelId().")";
                try {
                        if(is_null($this->db->query($sql,__LINE__,__FILE__))) {
                                throw new Exception('Query to add item was 
unsuccessful');
@@ -120,7 +124,7 @@
                if(!$this->checkIfBimItemExists($bimItem->getGuid())) {
                        throw new Exception("Item does not exist!");
                }
-               $sql = "Update ".self::bimItemTable." set 
xml_representation='".$bimItem->getXml()."' where 
guid='".$bimItem->getGuid()."'";
+               $sql = "Update ".self::bimItemTable." set 
xml_representation='".$this->db->db_addslashes($bimItem->getXml())."' where 
guid='".$bimItem->getGuid()."'";
                
         if(is_null($this->db->query($sql,__LINE__,__FILE__) )){
                        throw new Exception("Error updating xml of bim item!");
@@ -149,7 +153,7 @@
                        throw new Exception('Error!');
                } else {
                        $this->db->next_record();
-                       $result = $this->db->f($columnAlias);
+                       $result = $this->db->f($columnAlias,true);
                        return preg_split('/,/', $result);
                        //$match; // xpath result from database will look like: 
'{data1, data2, data3}', or '{}' for no results
                        //preg_match('/^\{(.*)\}$/', $result, $match);
@@ -196,4 +200,4 @@
        }
 
        
-}
\ No newline at end of file
+}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]