Пример #1
0
function sql_query($query, $id)
{
    global $dbtype;
    global $sql_debug;
    $sql_debug = 0;
    if ($sql_debug) {
        echo "SQL query: " . str_replace(",", ", ", $query) . "<BR>";
    }
    switch ($dbtype) {
        case "MySQL":
            $res = @mysql_query($query, $id);
            return $res;
            break;
        case "mSQL":
            $res = @msql_query($query, $id);
            return $res;
            break;
        case "postgres":
        case "postgres_local":
            $res = pg_exec($id, $query);
            $result_set = new ResultSet();
            $result_set->set_result($res);
            $result_set->set_total_rows(sql_num_rows($result_set));
            $result_set->set_fetched_rows(0);
            return $result_set;
            break;
        case "ODBC":
        case "ODBC_Adabas":
            $res = @odbc_exec($id, $query);
            return $res;
            break;
        case "Interbase":
            $res = @ibase_query($id, $query);
            return $res;
            break;
        case "Sybase":
            $res = @sybase_query($query, $id);
            return $res;
            break;
        default:
            break;
    }
}