Struct query_builder::DeleteQuery
[−]
[src]
pub struct DeleteQuery<'a, 'c> { pub whre: Vec<WhereClause<'a, 'c>>, // some fields omitted }
Struct representing a SQL Delete Statement
Fields
whre: Vec<WhereClause<'a, 'c>>
Methods
impl<'a, 'c> DeleteQuery<'a, 'c>
[src]
pub fn from(table: &'a str) -> DeleteQuery
[src]
Return a new DeleteQuery
that deletes data from table table
pub fn limit(&mut self, limit: usize)
[src]
Sets the limit of items to delete
Example
use query_builder::{DeleteQuery, Value, WhereClause}; let mut query = DeleteQuery::from("users"); // add values to delete query.whre.push(WhereClause::new("name", Value::Varchar("gregory"), None)); // add the limit query.limit(1); // make sure the query looks like expected assert_eq!(query.as_string(), "DELETE FROM users WHERE name = 'gregory' LIMIT 1");
pub fn get_limit(&self) -> Option<usize>
[src]
Returns the limit of the DeleteQuery
Example
use query_builder::{DeleteQuery, Value}; // create query let mut query = DeleteQuery::from("users"); // set the limit query.limit(12); assert_eq!(query.get_limit(), Some(12));
pub fn clear_limit(&mut self)
[src]
Removes the limit from the DeleteQuery
Example
use query_builder::DeleteQuery; let mut query = DeleteQuery::from("users"); /* add limit to the query */ query.limit(12); assert_eq!(query.get_limit(), Some(12)); /* clear the limit */ query.clear_limit(); assert_eq!(query.get_limit(), None);
pub fn order_by(&mut self, ob: OrderBy<'c>)
[src]
Adds a OrderBy
clause to the query
Example
use query_builder::{DeleteQuery, OrderBy}; let mut query = DeleteQuery::from("continents"); query.order_by(OrderBy::Row("population")); assert_eq!(query.as_string(), "DELETE FROM continents ORDER BY population");
pub fn is_ordered(&self) -> bool
[src]
Returns either true
or false
depending on whether
or not the DeleteQuery
contains a OrderBy
clause
Example
use query_builder::{DeleteQuery, OrderBy}; let mut query = DeleteQuery::from("states"); query.order_by(OrderBy::Row("population")); assert!(query.is_ordered());
pub fn clear_order_by(&mut self)
[src]
Removes the ORDER BY clause from the query
pub fn as_string(&self) -> String
[src]
Return a String
representing the [DeleteQuery
]
Example
use query_builder::{DeleteQuery, Value, WhereClause, Condition}; // create basic query let mut query = DeleteQuery::from("people"); // set parameter of the query query.whre.push(WhereClause::new("name", Value::Varchar("justine"), None)); query.whre.push(WhereClause::new("age", Value::Int(24), Some(Condition::And))); query.limit(1); assert_eq!(query.as_string(), "DELETE FROM people WHERE name = 'justine' AND age = 24 LIMIT 1");
Trait Implementations
impl<'a, 'c> Debug for DeleteQuery<'a, 'c>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<'a, 'c> Display for DeleteQuery<'a, 'c>
[src]
fn fmt(&self, f: &mut Formatter) -> FormatResult
[src]
Formats the value using the given formatter. Read more