コード例 #1
0
 /**
  * Store the given I2CE_MagicDataNode into the database.
  * @param I2CE_MagicDataNode $node
  */
 public function store($node)
 {
     if ($node instanceof I2CE_MagicData) {
         $parent = '';
         $name = '';
         $path = '/';
     } else {
         $name = $node->getName();
         if (is_string($name) && strlen($name) == 0) {
             I2CE::raiseError("Non-existent name on a non-root magic data node");
             return false;
         }
         $parentNode = $node->getParent();
         if ($parentNode instanceof I2CE_MagicData) {
             $parent = '/';
             $path = '/' . $name;
         } else {
             $parent = $parentNode->getPath(false);
             $path = $parent . '/' . $name;
         }
     }
     $value = $node->getSaveValue();
     //$path_hash = md5($path);
     $path_hash = $this->getHash($node);
     if ($this->db_statements['store']->execute(array($path_hash, $parent, $name, $node->getType(), $value))) {
         return true;
     } else {
         I2CE_MagicDataNode::raiseError("Error saving to DB " . $node->getPath() . " Type: " . $node->getType() . " Value: " . $value);
         return false;
     }
 }