method init documentation in bbn\Db\Sync2

function(bbn\Db $db, array $sync_cfg = [], array $tables = [], string $sync_table = '') { if ($this->is_init) { throw new \Exception("Impossible to init twice the dbsync class"); } $this->current_connection = $db; if (!empty($sync_table)) { $this->sync_table = $sync_table; } if (!Str::checkName($this->sync_table)) { throw new \Exception(X::_("Table name not allowed")); } if (empty($sync_cfg)) { $this->sync_connection = new Db(self::$default_cfg); } elseif (isset($sync_cfg['connection'])) { if (is_object($sync_cfg['connection']) && (is_a($sync_cfg['connection'], '\\bbn\\Db') || is_subclass_of($sync_cfg['connection'], '\\bbn\\Db')) ) { $this->sync_connection = $sync_cfg['connection']; } else { throw new \Exception(X::_("Invalid connection given to the synchronization class")); } } elseif (isset($sync_cfg['engine'])) { if (($sync_cfg['engine'] === 'sqlite') || ($sync_cfg['engine'] !== $this->current_connection->getEngine()) ) { $this->sync_connection = new Db($sync_cfg); } elseif (isset($sync_cfg['db']) && !isset($sync_cfg['user'])) { $this->sync_connection =& $this->current_connection; $this->sync_table = $this->sync_connection->tfn($this->sync_table, $sync_cfg['db']); } } elseif (isset($sync_cfg['db']) && !isset($sync_cfg['user'])) { $this->sync_connection =& $this->current_connection; $this->sync_table = $this->sync_connection->tfn($this->sync_table, $sync_cfg['db']); } $this->tables = $tables; $this->is_init = true; if (\count($this->tables) === 0) { $this->tables = $this->current_connection->getTables(); } if (\is_array($this->tables)) { foreach ($this->tables as $i => $t){ $this->tables[$i] = $this->current_connection->tableFullName($t); } $this->current_connection->setTrigger( '\\bbn\Db\\sync::trigger', ['delete', 'update', 'insert'], ['before', 'after'], $this->tables ); } }

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.