method getHistory documentation in bbn\Appui\History
function(string $table, string $id, string $col = '')
{
self::check($table) &&
($modelize = self::getTableCfg($table))
){
$pat = [
'ins' => 'INSERT',
'upd' => 'UPDATE',
'res' => 'RESTORE',
'del' => 'DELETE'
];
$r = [];
$fields = [
'date' => 'tst',
'user' => 'usr',
'col'
];
$where = [
'uid' => $id
];
if ( !empty($col) ){
if ( !Str::isUid($col) ){
$fields[] = $modelize['fields'][$col]['type'] === 'binary' ? 'ref' : 'val';
$col = self::$database_obj->columnId($col, $table);
}
else {
$idx = X::find($modelize['fields'], ['id_option' => strtolower($col)]);
if (null === $idx) {
throw new Exception("Impossible to find the option $col");
}
$fields[] = $modelize['fields'][$idx]['type'] === 'binary' ? 'ref' : 'val';
}
$where['col'] = $col;
}
else {
$fields[] = 'val';
$fields[] = 'ref';
}
foreach ( $pat as $k => $p ){
$where['opr'] = $p;
if ( $q = self::$db->rselectAll([
'table' => self::$table,
'fields' => $fields,
'where' => [
'conditions' => $where
],
'order' => [[
'field' => 'tst',
'dir' => 'desc'
]]
]) ){
$r[$k] = $q;
}
}
return $r;
}
}
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