public function DataQuery::execute in Data 6
Build and execute a query.
File
- includes/
DataHandler.inc, line 239 - Definition of DataHandler class.
Class
- DataQuery
- Builds and executes a query, only delete queries are supported at the moment.
Code
public function execute() {
$table = db_escape_table($this->table);
$query = "DELETE " . implode(', ', $this->subject);
$query .= " FROM {{$table}} {$table}";
if (!empty($this->join)) {
foreach ($this->join as $table => $join) {
$table = db_escape_table($table);
$clause = array_shift($join);
$join = array_shift($join);
$query .= " {$join} {{$table}} {$table} ON {$clause}";
}
}
$where = $values = array();
foreach ($this->where as $k => $v) {
$where[] = $k;
if ($v !== NULL) {
$values[] = $v;
}
}
if (!empty($where)) {
$query .= " WHERE " . implode(' AND ', $where);
}
return db_query($query, $values);
}