/** * Sets the cluster for the next query * If no parameter is present, the cluster of the active session is used. * By default the function expects a cluster number until you use $lookup=true, then DB::getCluster() is used to obtain the cluster number * * @param integer $srv Server number or the number for lookup * @param boolean $lookup lookup the number or use it direclty */ public static final function setCluster($srv = null, $lookup = false) { return DB::setCluster($srv, $lookup); }
/** * Internal callback for hash-codes * * @param char $c The current code after a hash * @return string Returns the string value of the parameter or something else to the hash-code */ private static function _escape($c) { switch ($c) { case 'u': DB::setCluster($_SESSION['SRV']); case 'U': return $_SESSION['UID']; case 's': return mysqli_quote(DB::$args[++DB::$a]); case 'i': return (int) DB::$args[++DB::$a]; case 'f': return (double) DB::$args[++DB::$a]; case 'o': $val =& DB::$args[++DB::$a]; if (isset($val['UID'])) { if (isset($val['UCluster'])) { DB::setCluster($val['UCluster']); } else { DB::setCluster($val['UID'], true); } return $val['UID']; } else { DB::setCluster($val, true); return (int) $val; } case 'x': return '0x' . bin2hex(DB::$args[++DB::$a]); case 'X': return '0x' . DB::$args[++DB::$a]; case 'm': if (empty(DB::$args[++DB::$a])) { return 'NULL'; } return mysqli_quote(DB::$args[DB::$a]); case 'h': return mysqli_quote(htmlspecialchars(DB::$args[++DB::$a])); case 'r': return sprintf('%u', ip2long(DB::$args[++DB::$a])); case 'd': return date("'Y-m-d'", DB::$args[++DB::$a]); case 't': return date("'Y-m-d H:m:s'", DB::$args[++DB::$a]); case 'n': return date("'Y-m-d H:m:s'", $_SERVER['REQUEST_TIME']); case 'v': return empty(DB::$args[++DB::$a]) ? 'NULL' : "''"; // Bool // Bool case 'a': return implode(',', array_map('mysqli_quote', DB::$args[++DB::$a])); case 'J': // http://www.xarg.org/2010/06/optimized-way-of-getting-subqueries-at-once-using-json/ $fields = DB::$args[++DB::$a]; $str = "CONCAT('[',GROUP_CONCAT(CONCAT('{\""; for ($i = 0, $l = count($fields); $i < $l; ++$i) { $str .= $fields[$i] . "\":',QUOTE(" . $fields[$i]; if ($i != $l - 1) { $str .= "),'\",\""; } } $str .= "),'}')),']')"; return $str; } return 'FAILED'; }