method getTableCfg documentation in bbn\Appui\History
Gets all information about a given table
function(string $table, bool $force = false)
{
// Check history is enabled and table's name correct
if (
($db = self::_get_db()) &&
($dbc = self::_get_database()) &&
($table = $db->tfn($table))
){
if ( $force || !isset(self::$structures[$table]) ){
if ( $model = $dbc->modelize($table) ){
self::$structures[$table] = [
'history' => false,
'primary' => false,
'primary_type' => null,
'primary_length' => 0,
'auto_increment' => false,
'id' => null,
'fields' => []
];
if (
self::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
self::$structures[$table]['history'] = 1;
self::$structures[$table]['primary'] = $primary;
self::$structures[$table]['primary_type'] = $model['fields'][$primary]['type'];
self::$structures[$table]['primary_length'] = $model['fields'][$primary]['maxlength'];
self::$structures[$table]['auto_increment'] = isset($model['fields'][$primary]['extra']) && ($model['fields'][$primary]['extra'] === 'auto_increment');
self::$structures[$table]['id'] = $dbc->tableId($db->tsn($table), $db->getCurrent());
self::$structures[$table]['fields'] = array_filter($model['fields'], function($a){
return isset($a['id_option']);
});
}
}
}
// The table exists and has history
if ( isset(self::$structures[$table]) && !empty(self::$structures[$table]['history']) ){
return self::$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-2023
BBN Solutions