/**
 * Helper function for db_query().
 *
 * @access private
 * @static
 */
function xanth_mysql_query_callback($match, $init = FALSE)
{
    static $args = NULL;
    if ($init) {
        $args = $match;
        return;
    }
    switch ($match[1]) {
        case '%d':
            return (int) array_shift($args);
        case '%s':
            return xDBMysql::escapeString(array_shift($args));
        case '%%':
            return '%';
        case '%f':
            return (double) array_shift($args);
        case '%b':
            // binary data
            return xDBMysql::encodeBlob(array_shift($args));
    }
}