/// <inheritDoc /> public override string GetLastInsertId(PDO pdo, string name) { //http://php.net/manual/en/function.db2-last-insert-id.php#98361 //https://www.ibm.com/support/knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.sql.ref.doc/doc/r0004231.html using (var cmd = pdo.CreateCommand("SELECT IDENTITY_VAL_LOCAL() AS LASTID FROM SYSIBM.SYSDUMMY1")) { object value = cmd.ExecuteScalar(); return(value?.ToString()); } }
/// <summary> /// Initializes a new instance of the <see cref="PDOStatement" /> class. /// </summary> /// <param name="pdo">The pdo.</param> /// <param name="statement">The statement.</param> /// <param name="driver_options">The driver options.</param> internal PDOStatement(PDO pdo, string statement, PhpArray driver_options) { this.m_pdo = pdo; this.m_stmt = statement; this.m_options = driver_options ?? PhpArray.Empty; this.m_cmd = pdo.CreateCommand(this.m_stmt); this.SetDefaultAttributes(); }
/// <summary> /// 2 phase ctor. /// Prepares the command. /// </summary> /// <param name="pdo"></param> /// <param name="queryString"></param> /// <param name="options">Driver options. Optional.</param> internal void Prepare(PdoConnectionResource pdo, string queryString, PhpArray options) { pdo.ClosePendingReader(); // initialize properties this.Connection = pdo ?? throw new ArgumentNullException(nameof(pdo)); this.queryString = queryString; // var actualQuery = Driver.RewriteCommand(queryString, options, out bound_param_map); _cmd = PDO.CreateCommand(actualQuery); //_cmd.Prepare(); // <-- compiles the query, needs parameters to be bound }
/// <summary> /// Initializes a new instance of the <see cref="PDOStatement" /> class. /// </summary> /// <param name="ctx">The php context.</param> /// <param name="pdo">The PDO statement is created for.</param> /// <param name="statement">The statement.</param> /// <param name="driver_options">The driver options.</param> internal PDOStatement(Context ctx, PDO pdo, string statement, PhpArray driver_options) { if (pdo.HasExecutedQuery) { if (!pdo.StoreLastExecutedQuery()) { pdo.HandleError(new PDOException("Last executed PDOStatement result set could not be saved correctly.")); } } this.m_pdo = pdo; this._ctx = ctx; this.m_stmt = statement; this.m_options = driver_options ?? PhpArray.Empty; this.m_cmd = pdo.CreateCommand(this.m_stmt); PrepareStatement(); this.SetDefaultAttributes(); }