Postgres::createRule PHP Метод

createRule() публичный Метод

Creates a rule
public createRule ( $name, $event, $table, $where, $instead, $type, $action, $replace = false ) : -1
$name The name of the new rule
$event SELECT, INSERT, UPDATE or DELETE
$table Table on which to create the rule
$where When to execute the rule, '' indicates always
$instead True if an INSTEAD rule, false otherwise
$type NOTHING for a do nothing rule, SOMETHING to use given action
$action The action to take
$replace (optional) True to replace existing rule, false otherwise
Результат -1
    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);
    }
Postgres