2011-12-01 48 views

回答

1

你可以做的就是最後執行的是這樣的查詢:

 
$mysql_last_query = ""; //this var contains the last mysql query 
function query($sql, $args) { #sintax: query("query", "arg1", "arg2", "argn"); EXAMPLE: query("select * from %s", $_GET["table"]); 
    global $mysql_last_query; 
    $args = func_get_args(); 
    if(($num = func_num_args()) > 1) 
     $sql = call_user_func_array("sprintf", $args); 
    $mysql_last_query = $sql; 
    return mysql_query($sql); 
} 
function select($table, $what = "*", $where = "", $limit = ""){ #this function is a "shortcut" for mysql select EXAMPLE: select("blah"); //SELECT * FROM blah and so on 
    return mysql_query("SELECT ".$what." FROM ".$table.($where == "" ? "":(" WHERE ".$where)).($limit == "" ? "":(" LIMIT ".$limit))); 
} 

希望它可以幫助