public function __construct($e, $sql = null) { if (!php_Boot::$skip_constructor) { parent::__construct(null, _hx_anonymous(array("fileName" => "Error.hx", "lineNumber" => 78, "className" => "system.base.BadSQLException", "methodName" => "new"))); $strings = null; $strings = _hx_string_call($e, "split", array(";")); haxe_Log::trace(system_base_Sql_colour::pretify($sql), _hx_anonymous(array("fileName" => "Error.hx", "lineNumber" => 81, "className" => "system.base.BadSQLException", "methodName" => "new"))); haxe_Log::trace(system_base_Sql_colour::pretify($strings[0]), _hx_anonymous(array("fileName" => "Error.hx", "lineNumber" => 82, "className" => "system.base.BadSQLException", "methodName" => "new"))); system_base_Error::wipe("SQL said: " . _hx_string_or_null($strings[1])); } }
static function pretify($sql) { $position = 0; $completed = 0; $start = 0; $end = 0; $skips = null; $c = null; $literals = new _hx_array(array()); while ($position <= strlen($sql)) { $c = _hx_char_at($sql, $position++); switch ($c) { case "\\": $position += 1; break; case "'": $start = $position; $skips = system_base_Sql_colour::skippy(system_base_Sql_colour::$QUOTE, $sql, $position); $end = $skips->position; $skips = system_base_Sql_colour::now_in_colour($sql, $completed, $start, $end, null); $sql = $skips->string; $completed = $skips->position; $position = $completed + 1; break; case "\"": $start = $position; $skips = system_base_Sql_colour::skippy(system_base_Sql_colour::$QUOTES, $sql, $position); $end = $skips->position; $skips = system_base_Sql_colour::now_in_colour($sql, $completed, $start, $end, null); $sql = $skips->string; $completed = $skips->position; $position = $completed + 1; break; case "`": $start = $position; $skips = system_base_Sql_colour::skippy(system_base_Sql_colour::$REV_TICK, $sql, $position); $end = $skips->position; $skips = system_base_Sql_colour::now_in_colour($sql, $completed, $start, $end, system_base_Sql_colour::$REV_TICK); $sql = $skips->string; $completed = $skips->position; $position = $completed + 1; break; } } $sql = system_base_Sql_colour::now_in_colour($sql, $completed, $position, $position, null)->string; $sql = system_base_Sql_colour::$NEWLINE->replace($sql, "<br>"); $sql = system_base_Sql_colour::$TAB->replace($sql, " "); return $sql; }
static function parse_query($sql_cmd, $args = null, $explain = null) { $i = null; $usr_sql = null; $strings = null; $strings = _hx_explode("?", $sql_cmd); $usr_sql = ""; if (system_base_Database::$cnx === null) { throw new HException(new system_base_Dbexception()); } if ($args !== null) { if ($strings->length - 1 !== $args->length) { throw new HException("Number of SQL arguments supplied must match the number of placeholders"); } $_g1 = 0; $_g = $args->length; while ($_g1 < $_g) { $i1 = $_g1++; if (Reflect::isObject($args[$i1])) { $usr_sql .= _hx_string_or_null($strings[$i1]) . "\"" . _hx_string_or_null(system_base_Database::$cnx->escape($args[$i1])) . "\""; } else { $usr_sql .= _hx_string_or_null($strings[$i1]) . _hx_string_or_null($args[$i1]); } unset($i1); } if ($strings->length > 0) { $usr_sql .= _hx_string_or_null($strings[$strings->length - 1]); } } else { $usr_sql = $sql_cmd; } if ($explain) { system_base_Sql_colour::pretify($usr_sql); } return $usr_sql; }