method getNextUpdate documentation in bbn\Db\History
function(string $table, string $id, $from_when, $column = NULL)
{
/** @todo To be redo totally with all the fields' IDs instead of the history column */
if (Str::checkName($table)
&& ($date = $this->validDate($from_when))
&& ($id_table = $this->database_obj->tableId($table))
) {
$this->disable();
$tab = $this->db->escape($this->getHistoryTableName());
$tab_uids = $this->db->escape($this->getHistoryUidsTableName());
$uid = $this->db->cfn($this->getHistoryUidsColumnName('bbn_uid'), $this->getHistoryUidsTableName());
$id_tab = $this->db->cfn($this->getHistoryUidsColumnName('bbn_table'),$this->getHistoryUidsTableName());
$id_col = $this->db->cfn($this->getHistoryTableColumnName('col'), $this->getHistoryTableName());
$line = $this->db->cfn($this->getHistoryTableColumnName('uid'), $this->getHistoryTableName());
$usr = $this->db->cfn($this->getHistoryTableColumnName('usr'), $this->getHistoryTableName());
$chrono = $this->db->cfn($this->getHistoryTableColumnName('tst'), $this->getHistoryTableName());
$where = [
$uid => $id,
$id_tab => $id_table,
[$chrono, '>', $date]
];
if ($column) {
$where[$id_col] = Str::isUid($column) ? $column : $this->database_obj->columnId($column, $id_table);
}
else {
$w = $this->_get_table_where($table);
//$where = $id_col." != UNHEX('$id_column') " . ($w ?: '');
}
$res = $this->db->rselect(
[
'tables' => [$tab_uids],
'fields' => [
$line,
$id_col,
$chrono,
'val' => 'IFNULL('.$this->getHistoryTableColumnName('val').', '.$this->getHistoryTableColumnName('ref').')',
$usr
],
'join' => [[
'table' => $tab,
'on' => [
'logic' => 'AND',
'conditions' => [[
'field' => $uid,
'operator' => '=',
'exp' => $line
]]
]]],
'where' => $where,
'order' => [$chrono => 'ASC']
]
);
$this->enable();
return $res;
}
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