method setTrigger documentation in bbn\Db\Languages\Sql

Apply a function each time the methods $kind are used

function(callable $function, $kind = NULL, $moment = NULL, $tables = '*') { $kinds = ['SELECT', 'INSERT', 'UPDATE', 'DELETE']; $moments = ['before', 'after']; if (empty($kind)) { $kind = $kinds; } elseif (!\is_array($kind)) { $kind = (array)strtoupper($kind); } else{ $kind = array_map('strtoupper', $kind); } if (empty($moment)) { $moment = $moments; } else { $moment = !\is_array($moment) ? (array)strtolower($moment) : array_map('strtolower', $moment); } foreach ($kind as $k){ if (\in_array($k, $kinds, true)) { foreach ($moment as $m){ if (array_key_exists($m, $this->_triggers[$k]) && \in_array($m, $moments, true)) { if ($tables === '*') { $tables = $this->getTables(); } elseif (Str::checkName($tables)) { $tables = [$tables]; } if (\is_array($tables)) { foreach ($tables as $table){ $t = $this->tableFullName($table); if (!isset($this->_triggers[$k][$m][$t])) { $this->_triggers[$k][$m][$t] = []; } $this->_triggers[$k][$m][$t][] = $function; } } } } } } return $this; }

Apply a function each time the methods $kind are used BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.