method trigger documentation in bbn\Db\Sync2

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 (!$this->disabled && $this->check() && (count($cfg['tables']) === 1) && ($table = $this->current_connection->tfn(current($cfg['tables']))) && \in_array($table, $this->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]; } } $this->sync_connection->insert( $this->sync_table, [ 'db' => $this->current_connection->getCurrent(), 'tab' => $this->current_connection->tsn($table), 'action' => $cfg['kind'], 'chrono' => microtime(true), 'rows' => empty($cfg['where']) ? '[]' : X::jsonBase64Encode($cfg['where']), 'vals' => empty($values) ? '[]' : X::jsonBase64Encode($values) ] ); } } 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.