An explicitly prepared statement.
Statements are prepared and cached by default, per connection. This type allows you to look at that cache in-between the statement being prepared and it being executed. This contains the expected columns to be returned and the expected parameter types (if available).
Statements can be re-used with any connection and on first-use it will be re-prepared and cached within the connection.
[src]
pub fn sql(self): string {
return (self as _Statement).sql();
}
The SQL of the statement.
[src]
pub fn sql(self): string {
return (self as _Statement).sql();
}
The SQL of the statement.
The SQL of the statement.
execute
pub fn execute(self, values: ..BindValue?): QueryResult throws SqlError
[src]
pub fn execute(self, values: ..BindValue?): QueryResult throws SqlError {
return try (self as _Statement).execute(build_bind_values(..values)) as QueryResult;
}
Execute the statement with the given values to bind to the parameters.
Returns the QueryResult
.
execute
pub fn execute(self, values: ..BindValue?): QueryResult throws SqlError
[src]
pub fn execute(self, values: ..BindValue?): QueryResult throws SqlError {
return try (self as _Statement).execute(build_bind_values(..values)) as QueryResult;
}
Execute the statement with the given values to bind to the parameters.
Returns the QueryResult
.
Execute the statement with the given values to bind to the parameters.
Returns the QueryResult
.
use sql.Connection;
let conn = try! Connection.connect("sqlite::memory:");
let stmt = try! conn.prepare("UPDATE users SET name = ? WHERE id = ?");
let result = try! stmt.execute("Alice", 1);
[src]
pub fn query(self, values: ..BindValue?): Rows throws SqlError {
return try (self as _Statement).query(build_bind_values(..values)) as Rows;
}
Query the statement with the given values to bind to the parameters and return the resulting rows.
[src]
pub fn query(self, values: ..BindValue?): Rows throws SqlError {
return try (self as _Statement).query(build_bind_values(..values)) as Rows;
}
Query the statement with the given values to bind to the parameters and return the resulting rows.
Query the statement with the given values to bind to the parameters and return the resulting rows.
use sql.Connection;
let conn = try! Connection.connect("sqlite::memory:");
let stmt = try! conn.prepare("SELECT * FROM users WHERE id = ?");
let rows = try! stmt.query(1);
[src]
pub fn query_one(self, values: ..BindValue?): Row? throws SqlError {
return try self.query(..values).next();
}
Query and return the first row.
[src]
pub fn query_one(self, values: ..BindValue?): Row? throws SqlError {
return try self.query(..values).next();
}
Query and return the first row.
Query and return the first row.
See: sql.Statement.query
use sql.Connection;
let conn = try! Connection.connect("sqlite::memory:");
let stmt = try! conn.prepare("SELECT * FROM users WHERE id = ?");
let row = try! stmt.query_one(1)!;
let name = try! row.get::<string>("name");