/** *Renames a child node * @param I2CE_MagicDataNode $node *@param string $old *@param string $new *@returns boolean. True on success, false on failure */ public function renameChild($node, $old, $new) { if ($node instanceof I2CE_MagicData) { $parentPath = '/'; $offset = strlen('/' . $old) + 1; $fullOffset = strlen($node->getPath(true) . '/' . $old); // if $old ='old', results in calling SUBSTR(parent,5) //so if parent = '/old/path' then substr(parent,5) = '/path' //we want to result in /new/path } else { $parentPath = $node->getPath(false); //e.g. $offset = strlen($node->getPath(false) . '/' . $old) + 1; $fullOffset = strlen($node->getPath(true) . '/' . $old); //child: if $old = 'old' and $node='/some', then calling SUBSTR(parent, 10) //so if parent = /some/old/path then substr(parent,10) = /path //we want to result in /some/new/path } $newPath = mysql_real_escape_string($this->getChildPath($node, $new, false)); $newFullPath = mysql_real_escape_string($this->getChildPath($node, $new, true)); $oldPath = mysql_real_escape_string($this->getChildPath($node, $old, false)); $qry_node = "UPDATE config_alt SET name = '" . mysql_real_escape_string($new) . "' , path_hash = '" . mysql_real_escape_string($this->getHash($node, $new)) . "' " . "WHERE parent = '" . mysql_real_escape_string($parentPath) . "' AND name = '" . mysql_real_escape_string($old) . "'"; //change direct children $qry_child = "UPDATE config_alt SET " . " path_hash = MD5(CONCAT('{$newFullPath}', '/',name)) " . ", parent = '{$newPath}' " . "WHERE parent = '{$oldPath}'"; //change descendents $qry_desc = "UPDATE config_alt SET " . " path_hash = MD5( CONCAT('{$newFullPath}', SUBSTR(parent,{$offset}) , '/',name)) " . ", parent = CONCAT('{$newPath}', SUBSTR(parent,{$offset}) ) " . "WHERE parent LIKE '{$oldPath}/%'"; $this->db->exec($qry_node); $this->db->exec($qry_child); $this->db->exec($qry_desc); return true; }
protected function _cleanUser($user) { $r = $this->_db->exec('DELETE FROM syncml_data WHERE syncml_uid = ' . $this->_db->quote($user, 'text')); $this->_checkForError($r); $r = $this->_db->exec('DELETE FROM syncml_map WHERE syncml_uid = ' . $this->_db->quote($user, 'text')); $this->_checkForError($r); $r = $this->_db->exec('DELETE FROM syncml_anchors WHERE syncml_uid = ' . $this->_db->quote($user, 'text')); $this->_checkForError($r); $r = $this->_db->exec('DELETE FROM syncml_uids WHERE syncml_uid = ' . $this->_db->quote($user, 'text')); $this->_checkForError($r); $r = $this->_db->exec('DELETE FROM syncml_suidlist WHERE syncml_uid = ' . $this->_db->quote($user, 'text')); $this->_checkForError($r); }
/** * (non-PHPdoc) * @see debugObject::msg() * @throws exceptions */ public function msg($msg, $level = DEBUG_INFO) { $msg = filter_var(trim($msg), FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); if (!empty($msg) && $_level & $level) { $t = microtime(true); $micro = round(($t - floor($t)) * 1000000); $d = new DateTime(date('Y-m-d H:i:s.' . $micro, $t)); $results = $this->_mdb2->exec('INSERT INTO ' . $this->_table . ' (level, message, time) VALUES (' . $this->_mdb2->quote($level, 'integer') . ', ' . $this->_mdb2->quote($msg, 'text') . ', ' . $this->_mdb2->quote($d->format('Y-m-d H:i:s.u'), 'text') . ')'); // error date with microtime ex. 2010-02-14 14:52:05.611046 if (PEAR::isError($results)) { throw new exceptions($results->getMessage(), $results->getCode()); } } }