public function parsePreparedParameters($parameters, &$blobs)
    {
        $types = '';
        $values = array();
        $blobs = array();
        $parametersCount = count($parameters);
        for ($index = 0; $index < $parametersCount; $index++) {
            $value = $parameters[$index];
            $phpType = gettype($value);

            // Allow overriding of parameter type using an associative array
            if ($phpType === 'array') {
                $phpType = $value['type'];
                $value = $value['value'];
            }

            // Convert php variable type to one that makes mysqli_stmt_bind_param happy
            // @see http://www.php.net/manual/en/mysqli-stmt.bind-param.php
            switch ($phpType) {
                case 'boolean':
                case 'integer':
                    $types .= 'i';
                    break;
                case 'float': // Not actually returnable from gettype
                case 'double':
                    $types .= 'd';
                    break;
                case 'object': // Allowed if the object or resource has a __toString method
                case 'resource':
                case 'string':
                case 'NULL': // Take care that a where clause should use "where XX is null" not "where XX = null"
                    $types .= 's';
                    break;
                case 'blob':
                    $types .= 'b';
                    // Blobs must be sent via send_long_data and set to null here
                    $blobs[] = array(
                        'index' => $index,
                        'value' => $value
                    );
                    $value = null;
                    break;
                case 'array':
                case 'unknown type':
                default:
                    user_error(
                        "Cannot bind parameter \"$value\" as it is an unsupported type ($phpType)",
                        E_USER_ERROR
                    );
                    break;
            }
            $values[] = $value;
        }
        return array_merge(array($types), $values);
    }