/** * Return an escaped string for use in a query. * * @param string $string The string to escape. * @param boolean $escapeall Set true to also escape _ and % for LIKE queries. * @return string */ public static function escape($string, $escapeall = false) { if (is_null(self::$dbconn)) { self::$dbconn = new DBConnection(); } if ($escapeall) { return addcslashes(self::$dbconn->id()->real_escape_string($string), '%_'); } else { return self::$dbconn->id()->real_escape_string($string); } }
public static function profile($sql, $time = 0) { if (KB_PROFILE == 2) { file_put_contents(self::$qerrfile, $sql . "\nExecution time: " . $time . "\n", FILE_APPEND); } if (KB_PROFILE == 3) { if (DB_TYPE == 'mysqli' && strtolower(substr($sql, 0, 6)) == 'select') { $dbconn = new DBConnection(); $prof_out_ext = $prof_out_exp = ''; $prof_qry = mysqli_query($dbconn->id(), 'EXPLAIN extended ' . $sql . ";"); while ($prof_row = mysqli_fetch_assoc($prof_qry)) { $prof_out_exp .= implode(' | ', $prof_row) . "\n"; } $prof_qry = mysqli_query($dbconn->id(), 'show warnings'); while ($prof_row = mysqli_fetch_assoc($prof_qry)) { $prof_out_ext .= implode(' | ', $prof_row) . "\n"; } file_put_contents(self::$qerrfile, $sql . "\n" . $prof_out_ext . $prof_out_exp . "\n-- Execution time: " . $time . " --\n", FILE_APPEND); } else { file_put_contents(self::$qerrfile, $sql . "\nExecution time: " . $time . "\n", FILE_APPEND); } } if (KB_PROFILE == 4) { if ($time > 0.1 && strtolower(substr($sql, 0, 6)) == 'select') { $dbconn = new DBConnection(); $prof_out_exp = $prof_out_exp = ''; $prof_qry = mysqli_query($dbconn->id(), 'EXPLAIN extended ' . $sql); while ($prof_row = mysqli_fetch_assoc($prof_qry)) { $prof_out_exp .= implode(' | ', $prof_row) . "\n"; } $prof_qry = mysqli_query($dbconn->id(), 'show warnings'); while ($prof_row = mysqli_fetch_assoc($prof_qry)) { $prof_out_ext .= implode(' | ', $prof_row) . "\n"; } file_put_contents(self::$qerrfile, $sql . "\n" . $prof_out_ext . $prof_out_exp . "\n-- Execution time: " . $time . " --\n", FILE_APPEND); } } }
function find_SQL_Version() { $conn = new DBConnection(); $value = (double) mysqli_get_server_info($conn->id()); return $value; }