method getRowBack documentation in bbn\Appui\History
function(string $table, string $id, $when, array $columns = [])
{
if ( !($when = self::validDate($when)) ){
self::_report_error("The date $when is incorrect", __CLASS__, __LINE__);
}
else if (
($db = self::_get_db()) &&
($cfg = self::getTableCfg($table))
){
// Time is after last modification: the current is given
self::disable();
if ( $when >= time() ){
$r = $db->rselect($table, $columns, [
$cfg['primary'] => $id
]) ?: null;
}
// Time is before creation: null is given
else if ( $when < self::getCreationDate($table, $id) ){
$r = null;
}
else {
// No columns = All columns
if ( \count($columns) === 0 ){
$columns = array_keys($cfg['fields']);
}
$r = [];
//die(var_dump($columns, $model['fields']));
foreach ( $columns as $col ){
$tmp = null;
if ( isset($cfg['fields'][$col]['id_option']) ){
if ($tmp = $db->rselect(self::$table, ['val', 'ref'], [
'uid' => $id,
'col' => $cfg['fields'][$col]['id_option'],
'opr' => 'UPDATE',
['tst', '>', $when],
['tst' => 'ASC']
])) {
$r[$col] = $tmp['ref'] ?: $tmp['val'];
}
}
if (!$tmp) {
$r[$col] = $db->selectOne($table, $col, [
$cfg['primary'] => $id
]);
}
}
}
self::enable();
return $r;
}
return null;
}
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