method importDb documentation in bbn\Appui\Database
Imports a database's structure into the options table.
function(string $db, string $host = '', $full = false)
{
$id_db = null;
if (Str::isUid($host)
&& ($engine = $this->o->parent($this->o->getIdParent($host)))
&& ($id_dbs = $this->o->fromCode('dbs', $engine['id']))
) {
if (!($id_db = $this->o->fromCode($db, $id_dbs))) {
if ($id_db = $this->o->add(
[
'id_parent' => $id_dbs,
'text' => $db,
'code' => $db,
]
)
) {
$this->o->setCfg($id_db, ['allow_children' => 1, 'show_code' => 1]);
}
}
if ($id_db) {
if (!($id_procedures = $this->o->fromCode('procedures', $id_db))
&& ($id_procedures = $this->o->add(
[
'id_parent' => $id_db,
'text' => X::_('Procedures'),
'code' => 'procedures',
]
))
) {
$this->o->setCfg(
$id_procedures,
[
'show_code' => 1,
'show_value' => 1,
'allow_children' => 1
]
);
}
if (!($id_connections = $this->o->fromCode('connections', $id_db))
&& ($id_connections = $this->o->add(
[
'id_parent' => $id_db,
'text' => X::_('Connections'),
'code' => 'connections',
]
))
) {
$this->o->setCfg(
$id_connections,
[
'show_alias' => 1,
'notext' => 1,
'id_root_alias' => self::getOptionId('connections'),
'root_alias' => 'Connections'
]
);
}
if (!($id_functions = $this->o->fromCode('functions', $id_db))
&& ($id_functions = $this->o->add(
[
'id_parent' => $id_db,
'text' => X::_('Function'),
'code' => 'functions',
]
))
) {
$this->o->setCfg(
$id_functions,
[
'show_code' => 1,
'show_value' => 1,
'allow_children' => 1
]
);
}
if (!($id_tables = $this->o->fromCode('tables', $id_db))
&& ($id_tables = $this->o->add(
[
'id_parent' => $id_db,
'text' => X::_('Tables'),
'code' => 'tables',
]
))
) {
$this->o->setCfg(
$id_tables,
[
'show_code' => 1,
'show_value' => 1,
'allow_children' => 1
]
);
}
if ($id_connections && $id_functions && $id_procedures && $id_tables) {
if (!$this->db->count(
'bbn_options', [
'id_parent' => $id_connections,
'id_alias' => $host
]
)) {
$this->o->add([
'id_parent' => $id_connections,
'id_alias' => $host
]);
}
if ($full) {
if (!empty($host)) {
try {
$conn = $this->connection($host, $engine['code'], $db);
}
catch (\Exception $e) {
throw new \Exception(X::_("Impossible to connect"));
}
$tables = $conn->getTables($db);
if (!empty($tables)) {
foreach ($tables as $t) {
$this->importTable($t, $id_db, $host);
}
}
}
}
}
else{
throw new \Exception(X::_("Impossible to find an host ID for DB")." ".$this->o->code($id_db));
}
}
}
return $id_db;
}
Imports a database's structure into the options table. 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.
© 2011-2024
BBN Solutions