示例#1
0
        /// <summary>
        /// Preprocesses the command for use with parameters.
        /// Returns updated query string, optionally creates the <paramref name="bound_param_map"/> with parameter name mapping.
        /// Most of ADO.NET drivers does not allow to use unnamed parameters - we'll rewrite them to named parameters.
        /// </summary>
        /// <param name="stmt">The original command text.</param>
        /// <param name="options">Custom options.</param>
        /// <param name="bound_param_map">Will be set to <c>null</c> or a map of user-provided names to rewritten parameter names.</param>
        public virtual string RewriteCommand(PDOStatement stmt, PhpArray options, out Dictionary <IntStringKey, IntStringKey> bound_param_map)
        {
            string queryString;

            //
            using (var rewriter = new StatementStringRewriter())
            {
                rewriter.ParseString(stmt.queryString);

                bound_param_map = rewriter.BoundParamMap;
                queryString     = rewriter.RewrittenQueryString;
            }

            //
            return(queryString);
        }
示例#2
0
        /// <summary>
        /// Preprocesses the command for use with parameters.
        /// Returns updated query string, optionally creates the <paramref name="bound_param_map"/> with parameter name mapping.
        /// Most of ADO.NET drivers does not allow to use unnamed parameters - we'll rewrite them to named parameters.
        /// </summary>
        /// <param name="queryString">The original command text.</param>
        /// <param name="options">Custom options.</param>
        /// <param name="bound_param_map">Will be set to <c>null</c> or a map of user-provided names to rewritten parameter names.</param>
        public virtual string RewriteCommand(string queryString, PhpArray options, out Dictionary <IntStringKey, IntStringKey> bound_param_map)
        {
            using (var rewriter = new StatementStringRewriter()
            {
                TranslateNamedParams = true,
            })
            {
                rewriter.ParseString(queryString);

                bound_param_map = rewriter.BoundParamMap;
                queryString     = rewriter.RewrittenQueryString;
            }

            //
            return(queryString);
        }