function MSD_DoSQL($sqlcommands, $limit = "")
{
    global $config, $out, $numrowsabs, $numrows, $num_befehle, $time_used, $sql;
    if (!isset($sql['parser']['sql_commands'])) {
        $sql['parser']['sql_commands'] = 0;
    }
    if (!isset($sql['parser']['sql_errors'])) {
        $sql['parser']['sql_errors'] = 0;
    }
    $sql['parser']['time_used'] = getmicrotime();
    if (!isset($config['dbconnection'])) {
        MSD_mysql_connect();
    }
    $out = $sqlcommand = "";
    $allSQL = explode(';', preg_replace('/\\r\\n|\\n/', '', $sqlcommands));
    $sql_queries = count($allSQL);
    if (!isset($allSQL[$sql_queries - 1])) {
        $sql_queries--;
    }
    if ($sql_queries == 1) {
        SQLParser($allSQL[0]);
        $sql['parser']['sql_commands']++;
        $out .= Stringformat($sql['parser']['sql_commands'], 4) . ": " . $allSQL[0] . "\n";
        $result = MSD_query($allSQL[0]) or die(SQLError($allSQL[0], mysql_error()));
    } else {
        for ($i = 0; $i < $sql_queries; $i++) {
            $allSQL[$i] = trim(rtrim($allSQL[$i]));
            if ($allSQL[$i] != "") {
                $sqlcommand .= $allSQL[$i];
                $sqlcommand = SQLParser($sqlcommand);
                //echo "$i: ".htmlentities($sqlcommand)."<br>";
                if ($sql['parser']['start'] == 0 && $sql['parser']['end'] == 0 && $sqlcommand != "") {
                    //sql complete
                    $sql['parser']['sql_commands']++;
                    $out .= Stringformat($sql['parser']['sql_commands'], 4) . ": " . $sqlcommand . "\n";
                    $result = MSD_query($sqlcommand) or die(SQLError($sqlcommand, mysql_error()));
                    $sqlcommand = "";
                }
            }
        }
    }
    $sql['parser']['time_used'] = getmicrotime() - $sql['parser']['time_used'];
}
示例#2
0
function MSD_DoSQL($sqlcommands, $limit = "")
{
    global $config, $out, $numrowsabs, $numrows, $num_befehle, $time_used, $sql;
    if (!isset($sql['parser']['sql_commands'])) {
        $sql['parser']['sql_commands'] = 0;
    }
    if (!isset($sql['parser']['sql_errors'])) {
        $sql['parser']['sql_errors'] = 0;
    }
    $sql['parser']['time_used'] = getmicrotime();
    if (!isset($config['dbconnection'])) {
        MSD_mysql_connect();
    }
    $out = $sqlcommand = '';
    $allSQL = splitSQLStatements2Array($sqlcommands);
    #explode(';',preg_replace('/\r\n|\n/', '', $sqlcommands));
    $sql_queries = count($allSQL);
    if (!isset($allSQL[$sql_queries - 1])) {
        $sql_queries--;
    }
    if ($sql_queries == 1) {
        SQLParser($allSQL[0]);
        $sql['parser']['sql_commands']++;
        $out .= Stringformat($sql['parser']['sql_commands'], 4) . ': ' . $allSQL[0] . "\n";
        $result = MSD_query($allSQL[0]);
    } else {
        for ($i = 0; $i < $sql_queries; $i++) {
            $allSQL[$i] = trim(rtrim($allSQL[$i]));
            if ($allSQL[$i] != "") {
                $sqlcommand .= $allSQL[$i];
                $sqlcommand = SQLParser($sqlcommand);
                if ($sql['parser']['start'] == 0 && $sql['parser']['end'] == 0 && $sqlcommand != '') {
                    //sql complete
                    $sql['parser']['sql_commands']++;
                    $out .= Stringformat($sql['parser']['sql_commands'], 4) . ': ' . $sqlcommand . "\n";
                    $result = MSD_query($sqlcommand);
                    $sqlcommand = "";
                }
            }
        }
    }
    $sql['parser']['time_used'] = getmicrotime() - $sql['parser']['time_used'];
}