public static function quote($str, $noarray = false) {

        if (is_string($str))
            return '\'' . addcslashes($str, "\n\r\\'\"\032") . '\'';

        if (is_int($str) or is_float($str))
            return '\'' . $str . '\'';

        if (is_array($str)) {
            if($noarray === false) {
                foreach ($str as &$v) {
                    $v = self::quote($v, true);
                }
                return $str;
            } else {
                return '\'\'';
            }
        }

        if (is_bool($str))
            return $str ? '1' : '0';

        return '\'\'';
    }

数据库函数,对数据进行过滤。