lib/SafeSQL.php
function _convert_var($var, $type) {
        switch($type) {
            case '%i':
            case '%I':
            // cast to integer
            settype($var, 'integer');
            break;
            case '%f':
            case '%F':
            // cast to float
            settype($var, 'float');
            break;
            case '%c':
            case '%C':
            // comma separate
            settype($var, 'array');
            for($_x = 0 , $_y = count($var); $_x < $_y; $_x++) {
                // cast to integers
                settype($var[$_x], 'integer');
            }
            $var = implode(',', $var);
            if($var == '') {
                // force 0, keep syntax from breaking
                $var = '0';
            }
            break;
            case '%l':
            case '%L':
            // comma separate
            settype($var, 'array');
            $var = implode(',', $var);
            break;
            case '%q':
            case '%Q':
            settype($var, 'array');
            // quote comma separate
            $var = "'" . implode("','", $var) . "'";
            break;
            case '%n':
            case '%N':
            if($var != 'NULL')
            $var = "'" . $var . "'";
            break;
        }
        return $var;
    }
function _convert_var($var, $type) {
        switch($type) {
            case '%i':
            case '%I':
            // cast to integer
            settype($var, 'integer');
            break;
            case '%f':
            case '%F':
            // cast to float
            settype($var, 'float');
            break;
            case '%c':
            case '%C':
            // comma separate
            settype($var, 'array');
            for($_x = 0 , $_y = count($var); $_x < $_y; $_x++) {
                // cast to integers
                settype($var[$_x], 'integer');
            }
            $var = implode(',', $var);
            if($var == '') {
                // force 0, keep syntax from breaking
                $var = '0';
            }
            break;
            case '%l':
            case '%L':
            // comma separate
            settype($var, 'array');
            $var = implode(',', $var);
            break;
            case '%q':
            case '%Q':
            settype($var, 'array');
            // quote comma separate
            $var = "'" . implode("','", $var) . "'";
            break;
            case '%n':
            case '%N':
            if($var != 'NULL')
            $var = "'" . $var . "'";
            break;
        }
        return $var;
    }
/*======================================================================*\
Function: _convert_var
Purpose:  convert a variable to the given type
Input:    $var - the variable
$type - the type to convert to:
%i, %I - cast to integer
%f, %F - cast to float
%c, %C - comma separate, cast each element to integer
%l, %L - comma separate, no quotes, no casting
%q, %Q - quote/comma separate
%n, %N - wrap value in single quotes unless NULL
\*======================================================================