public virtual PDOStatement prepare(string statement, PhpArray driver_options = null) { try { PDOStatement newStatement = CreateStatement(statement, driver_options); lastExecutedStatement = newStatement; return(newStatement); } catch (System.Exception ex) { this.HandleError(ex); return(null); } }
public PDOStatement prepare(string statement, PhpArray driver_options = null) { try { PDOStatement newStatement = this.m_driver.PrepareStatement(_ctx, this, statement, driver_options); lastExecutedStatement = newStatement; return(newStatement); } catch (System.Exception ex) { this.HandleError(ex); return(null); } }
public virtual PDOStatement query(string statement, params PhpValue[] args) { var stmt = lastExecutedStatement = CreateStatement(statement, null); if (args.Length > 0) { // Set the fetch mode, logic inside PDOStatement if (args[0].IsLong(out var mode) && stmt.setFetchMode((PDO_FETCH)mode, args.AsSpan(1))) { // ok } else { return(null); } }
/// <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); }
public PDOStatement query(string statement, params PhpValue[] args) { PDOStatement stmt = new PDOStatement(this, statement, null); if (args.Length > 0) { // Set the fetch mode, logic inside PDOStatement stmt.setFetchMode(args); } if (stmt.execute()) { return(stmt); } else { return(null); } }
public PDOStatement query(string statement, params PhpValue[] args) { PDOStatement stmt = new PDOStatement(this, statement, null); PDO_FETCH fetch = PDO_FETCH.FETCH_USE_DEFAULT; if (args.Length > 0) { PhpValue fetchMode = args[0]; if (fetchMode.IsInteger()) { int value = (int)fetchMode.Long; if (Enum.IsDefined(typeof(PDO_FETCH), value)) { fetch = (PDO_FETCH)value; } } } int?colNo = null; if (fetch == PDO_FETCH.FETCH_COLUMN) { if (args.Length > 2) { colNo = (int)args[1].ToLong(); } else { //TODO what to do if missing parameter ? fetch = PDO_FETCH.FETCH_USE_DEFAULT; } } string className = null; PhpArray ctorArgs = null; if (fetch == PDO_FETCH.FETCH_CLASS) { if (args.Length > 2) { className = args[1].ToStringOrNull(); if (args.Length > 3) { ctorArgs = args[2].ArrayOrNull(); } } else { //TODO what to do if missing parameter ? fetch = PDO_FETCH.FETCH_USE_DEFAULT; } } PhpValue?fetchObject = null; if (fetch == PDO_FETCH.FETCH_OBJ) { if (args.Length > 2) { fetchObject = args[1]; if (fetchObject.Value.IsNull) { //TODO passed object is null } } else { //TODO what to do if missing parameter ? fetch = PDO_FETCH.FETCH_USE_DEFAULT; } } if (stmt.execute()) { return(stmt); } else { return(null); } }
/// <inheritDoc /> public virtual PDOStatement PrepareStatement(PDO pdo, string statement, PhpArray driver_options) { PDOStatement stmt = new PDOStatement(pdo, statement, driver_options); return(stmt); }