function createRule($name, $event, $table, $where, $instead, $type, $action, $replace = false)
{
$f_schema = $this->_schema;
$this->fieldClean($f_schema);
$this->fieldClean($name);
$this->fieldClean($table);
if (!in_array($event, $this->rule_events)) {
return -1;
}
$sql = "CREATE";
if ($replace) {
$sql .= " OR REPLACE";
}
$sql .= " RULE \"{$name}\" AS ON {$event} TO \"{$f_schema}\".\"{$table}\"";
// Can't escape WHERE clause
if ($where != '') {
$sql .= " WHERE {$where}";
}
$sql .= " DO";
if ($instead) {
$sql .= " INSTEAD";
}
if ($type == 'NOTHING') {
$sql .= " NOTHING";
} else {
$sql .= " ({$action})";
}
return $this->execute($sql);
}