@@ -930,6 +930,23 @@ impl Connection {
930930 stmt. execute ( params)
931931 }
932932
933+ /// A convenience function for queries that are only run once.
934+ ///
935+ /// If an error is returned, it could have come from either the preparation
936+ /// or execution of the statement.
937+ ///
938+ /// On success, returns the resulting rows.
939+ ///
940+ /// ## Panics
941+ ///
942+ /// Panics if the number of parameters provided does not match the number
943+ /// expected.
944+ pub fn query < ' a > ( & ' a self , query : & str , params : & [ & ToSql ] ) -> Result < Rows < ' a > > {
945+ let ( param_types, columns) = try!( self . conn . borrow_mut ( ) . raw_prepare ( "" , query) ) ;
946+ let stmt = Statement :: new ( self , "" . to_owned ( ) , param_types, columns, Cell :: new ( 0 ) , true ) ;
947+ stmt. into_query ( params)
948+ }
949+
933950 /// Begins a new transaction.
934951 ///
935952 /// Returns a `Transaction` object which should be used instead of
@@ -1386,6 +1403,7 @@ trait DbErrorNew {
13861403
13871404trait RowsNew < ' a > {
13881405 fn new ( stmt : & ' a Statement < ' a > , data : Vec < Vec < Option < Vec < u8 > > > > ) -> Rows < ' a > ;
1406+ fn new_owned ( stmt : Statement < ' a > , data : Vec < Vec < Option < Vec < u8 > > > > ) -> Rows < ' a > ;
13891407}
13901408
13911409trait LazyRowsNew < ' trans , ' stmt > {
@@ -1413,6 +1431,8 @@ trait StatementInternals<'conn> {
14131431 -> Statement < ' conn > ;
14141432
14151433 fn conn ( & self ) -> & ' conn Connection ;
1434+
1435+ fn into_query ( self , params : & [ & ToSql ] ) -> Result < Rows < ' conn > > ;
14161436}
14171437
14181438trait ColumnNew {
0 commit comments