method getTableCfg documentation in bbn\Db\History
Gets all information about a given table
function(string $table, bool $force = false)
{
// Check history is enabled and table's name correct
if (($table = $this->db->tfn($table))) {
if ($force || !isset($this->structures[$table])) {
if ($model = $this->database_obj->modelize($table)) {
$this->structures[$table] = [
'history' => false,
'primary' => false,
'primary_type' => null,
'primary_length' => 0,
'auto_increment' => false,
'id' => null,
'fields' => []
];
if ($this->isLinked($table)
&& isset($model['keys']['PRIMARY'])
&& (\count($model['keys']['PRIMARY']['columns']) === 1)
&& ($primary = $model['keys']['PRIMARY']['columns'][0])
&& !empty($model['fields'][$primary])
) {
// Looking for the config of the table
$this->structures[$table]['history'] = 1;
$this->structures[$table]['primary'] = $primary;
$this->structures[$table]['primary_type'] = $model['fields'][$primary]['type'];
$this->structures[$table]['primary_length'] = $model['fields'][$primary]['maxlength'];
$this->structures[$table]['auto_increment'] = isset($model['fields'][$primary]['extra']) && ($model['fields'][$primary]['extra'] === 'auto_increment');
$this->structures[$table]['id'] = $this->database_obj->tableId($this->db->tsn($table), $this->db->getCurrent());
$this->structures[$table]['fields'] = array_filter(
$model['fields'], function ($a) {
return isset($a['id_option']);
}
);
}
}
}
// The table exists and has history
if (isset($this->structures[$table]) && !empty($this->structures[$table]['history'])) {
return $this->structures[$table];
}
}
return null;
}
Gets all information about a given 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