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

Methods

impl<'a, 'c> DeleteQuery<'a, 'c>
[src]

[src]

Return a new DeleteQuery that deletes data from table table

[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");

[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));

[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);
 

[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");

[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());

[src]

Removes the ORDER BY clause from the query

[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]

[src]

Formats the value using the given formatter. Read more

impl<'a, 'c> Display for DeleteQuery<'a, 'c>
[src]

[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<'a, 'c> Send for DeleteQuery<'a, 'c>

impl<'a, 'c> Sync for DeleteQuery<'a, 'c>