本文整理汇总了PHP中MDB2::exec方法的典型用法代码示例。如果您正苦于以下问题:PHP MDB2::exec方法的具体用法?PHP MDB2::exec怎么用?PHP MDB2::exec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDB2
的用法示例。
在下文中一共展示了MDB2::exec方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renameChild
/**
*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;
}
示例2: _cleanUser
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);
}
示例3: msg
/**
* (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());
}
}
}