@@ -111,8 +111,8 @@ Both methods take an array of parameters to bind to the query represented as
111111` &ToSql ` trait objects. ` execute ` returns the number of rows affected by the
112112query (or 0 if not applicable):
113113``` rust
114- let stmt = conn . prepare (" UPDATE foo SET bar = $1 WHERE baz = $2" );
115- let updates = stmt . execute ([& 1i32 as & ToSql , & & " biz" as & ToSql ]);
114+ let stmt = try ! ( conn . prepare (" UPDATE foo SET bar = $1 WHERE baz = $2" ) );
115+ let updates = try ! ( stmt . execute ([& 1i32 as & ToSql , & & " biz" as & ToSql ]) );
116116println! (" {} rows were updated" , updates );
117117```
118118` query ` returns an iterator over the rows returned from the database. The
@@ -123,15 +123,15 @@ columns are one-indexed.
123123let stmt = try ! (conn . prepare (" SELECT bar, baz FROM foo" ));
124124for row in try ! (stmt . query ([])) {
125125 let bar : i32 = row [1 ];
126- let baz : ~ str = row [" baz" ];
126+ let baz : StrBuf = row [" baz" ];
127127 println! (" bar: {}, baz: {}" , bar , baz );
128128}
129129```
130130In addition, ` PostgresConnection ` has a utility ` execute ` method which is useful
131131if a statement is only going to be executed once:
132132``` rust
133133let updates = try ! (conn . execute (" UPDATE foo SET bar = $1 WHERE baz = $2" ,
134- [& 1i32 as & ToSql , & & " biz" as & ToSql ]));
134+ [& 1i32 as & ToSql , & ( & " biz" ) as & ToSql ]));
135135println! (" {} rows were updated" , updates );
136136```
137137
0 commit comments