pike.git / lib / modules / __builtin.pmod / Sql.pmod / Connection.pike

version» Context lines:

pike.git/lib/modules/__builtin.pmod/Sql.pmod/Connection.pike:1217:    if (res && wild) {    res =    filter(res,    map(res->name,    Regexp(replace(wild, ({"%", "_"}), ({".*", "."})))->match));    }       return res;   }    - //! Sends a typed query to the database asynchronously, discards all query - //! result records. - //! - //! @returns - //! A @[Concurrent.Future] object which on failure/success passes - //! a @[Sql.FutureResult] object to evaluate the query. - //! - //! @seealso - //! @[promise_query()], @[promise_query_first_result()], - //! @[promise_query_result()], @[big_typed_query()] - public Concurrent.Future promise_query_discard(string q, -  void|mapping(string|int:mixed) bindings) { -  Concurrent.Promise p = Concurrent.Promise(); -  .FutureResult(this, p, q, bindings, 0); -  return p->future(); - } -  - //! Sends a typed query to the database asynchronously, expects at least - //! a single record from the database (will fail otherwise); - //! will discard any further records. - //! - //! @returns - //! A @[Concurrent.Future] object which on failure/success passes - //! a @[Sql.FutureResult] object to evaluate the query. - //! - //! @seealso - //! @[promise_query()], @[promise_query_result()], - //! @[promise_query_discard()], @[big_typed_query()] - public Concurrent.Future promise_query_first_result(string q, -  void|mapping(string|int:mixed) bindings) { -  Concurrent.Promise p = Concurrent.Promise(); -  .FutureResult(this, p, q, bindings, 1); -  return p->future(); - } -  - //! Sends a typed query to the database asynchronously, expects at least - //! a single record from the database (will fail otherwise). - //! - //! @returns - //! A @[Concurrent.Future] object which on failure/success passes - //! a @[Sql.FutureResult] object to evaluate the query. - //! - //! @seealso - //! @[promise_query()], @[promise_query_first_result()], - //! @[promise_query_discard()], @[big_typed_query()] - public Concurrent.Future promise_query_result(string q, -  void|mapping(string|int:mixed) bindings) { -  Concurrent.Promise p = Concurrent.Promise(); -  .FutureResult(this, p, q, bindings, 2); -  return p->future(); - } -  +    //! Sends a typed query to the database asynchronously.   //!   //! @returns - //! A @[Concurrent.Future] object which on failure/success passes - //! a @[Sql.FutureResult] object to evaluate the query. + //! An @[Sql.Promise] object which can be used to obtain + //! an @[Sql.FutureResult] object to evaluate the query.   //!   //! @seealso - //! @[promise_query_first_result()], @[promise_query_result()], - //! @[promise_query_discard()], @[big_typed_query()] + //! @[big_typed_query()], @[Sql.Promise], @[Sql.FutureResult]   //!   //! @example   //! @code   //!   //! Sql.Connection db = Sql.Connection("..."); - //! Concurrent.Future q1 = db->promise_query("SELECT 42"); - //! Concurrent.Future q2 = db->promise_query("SELECT :foo::INT", (["foo":2])); + //! Sql.Promise q1 = db->promise_query("SELECT 42")->max_records(10); + //! Sql.Promise q2 = db->promise_query("SELECT :foo::INT", (["foo":2]));   //! - //! array(Concurrent.Future) all = ({ q1, q2 }); + //! array(Concurrent.Future) all = ({ q1, q2 })->future();   //!   //! // To get a callback for each of the requests   //!   //! all->on_success(lambda (Sql.FutureResult resp) {   //! werror("Got result %O from %O\n", resp->data, resp->query);   //! });   //! all->on_failure(lambda (Sql.FutureResult resp) {   //! werror("Request %O failed: %O\n", resp->query,   //! resp->status_command_complete);   //! });
pike.git/lib/modules/__builtin.pmod/Sql.pmod/Connection.pike:1311:   //! Concurrent.Future all2 = Concurrent.results(all);   //!   //! all2->on_success(lambda (array(Sql.FutureResult) resp) {   //! werror("All requests were successful: %O\n", resp);   //! });   //! all->on_failure(lambda (Sql.FutureResult resp) {   //! werror("Requests %O failed with %O.\n", resp->query,   //! resp->status_command_complete);   //! });   //! @endcode - public Concurrent.Future promise_query(string q, + public .Promise promise_query(string q,    void|mapping(string|int:mixed) bindings) { -  Concurrent.Promise p = Concurrent.Promise(); -  .FutureResult(this, p, q, bindings, 3); -  return p->future(); +  return __builtin.Sql.Promise(this, q, bindings);   }