- 01
 - 02
 - 03
 - 04
 - 05
 - 06
 - 07
 - 08
 - 09
 - 10
 - 11
 - 12
 - 13
 - 14
 - 15
 - 16
 - 17
 - 18
 - 19
 - 20
 - 21
 - 22
 - 23
 - 24
 - 25
 - 26
 - 27
 - 28
 - 29
 - 30
 - 31
 - 32
 - 33
 - 34
 - 35
 
                        function query_safe()
	{
		$time_before = $this->get_real_time();
		if(!$this->connected) $this->connect(DBUSER, DBPASS, DBNAME, DBHOST);
		
		$args = func_get_args();
        $tmpl =& $args[0];
        $tmpl = str_replace("%", "%%", $tmpl);
        $tmpl = str_replace("?", "%s", $tmpl);
        foreach ($args as $i=>$v) {
            if(!$i) continue;
            if(is_int($v)) continue;
            $args[$i] = "'".mysql_escape_string($v)."'";
        }
        for($i=$c=count($args)-1; $i<$c+20; $i++)
            $args[$i+1] = "UNKNOWN_SQL_COMMAND_$i";
        
        $sql = call_user_func_array("sprintf", $args);
        //echo $sql;
        exit;
        
		if(!($this->query_id = mysql_query($sql, $this->db_id) )) {
			$this->mysql_error = mysql_error();
			$this->mysql_error_num = mysql_errno();
			if($show_error) {
				$this->display_error($this->mysql_error, $this->mysql_error_num, $query);
			}
		}
		
		$this->MySQL_time_taken += $this->get_real_time() - $time_before;
		$this->query_num ++;
		return $this->query_id;
	}
                                 
        
Использование:
$db->query_safe("select * from accounts where email=?", $_POST['email']);
Похоже строки 20 и 21 добавил говнокодер, который не смог разобраться в аццки сложной функции.
фрагмент
единственное гавно которое здесь написано (имхо), но его можно смело комментировать.