method trigger documentation in bbn\Db\Sync

Writes new rows in the sync table after a writing operation has happened.

function(array $cfg) { /** @todo I would like to understand... */ if (!isset($cfg['run'])) { $cfg['run'] = 1; } if (!isset($cfg['trig'])) { $cfg['run'] = 1; } if (!self::$disabled && self::check() && (count($cfg['tables']) === 1) && ($table = self::$current_connection->tfn(current($cfg['tables']))) && \in_array($table, self::$tables, true) ) { if ($cfg['moment'] === 'after') { // Case where we actually delete or restore through the $hcol column $values = []; if (X::hasProps($cfg, ['fields', 'values'], true)) { foreach ($cfg['fields'] as $i => $f) { $values[$f] = $cfg['values'][$i]; } } $last_id = self::$sync_connection->lastId(); self::$sync_connection->insert( self::$sync_table, [ 'db' => self::$current_connection->getCurrent(), 'tab' => self::$current_connection->tsn($table), 'action' => $cfg['kind'], 'chrono' => microtime(true), 'rows' => empty($cfg['where']) ? '[]' : X::jsonBase64Encode($cfg['where']), 'vals' => empty($values) ? '[]' : X::jsonBase64Encode($values) ] ); self::$sync_connection->setLastInsertId($last_id); } } return $cfg; }

Writes new rows in the sync table after a writing operation has happened. 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.