method getColumnHistory documentation in bbn\Db\History

function(string $table, string $id, string $column) { if ($this->check() && ($primary = $this->db->getPrimary($table)) && ($modelize = $this->getTableCfg($table)) ) { if (Str::isUid($column)) { $column = X::find($modelize['fields'], ['id_option' => strtolower($column)]); } if (null === $column || !isset($modelize['fields'][$column])) { throw new \Error(X::_("Impossible to find the option $column")); } $current = $this->db->selectOne( $table, $column, [ $primary[0] => $id ] ); $val = $modelize['fields'][$column] === 'binary' ? $this->getHistoryTableColumnName('ref') : $this->getHistoryTableColumnName('val'); $hist = $this->getHistory($table, $id, $column); $r = []; if ($crea = $this->getCreation($table, $id)) { if (!empty($hist['upd'])) { $hist['upd'] = array_reverse($hist['upd']); foreach ($hist['upd'] as $i => $h){ if ($i === 0) { $r[] = [ 'date' => $crea['date'], $val => $h[$val], 'user' => $crea['user'] ]; } else{ $r[] = [ 'date' => $hist['upd'][$i - 1]['date'], $val => $h[$val], 'user' => $hist['upd'][$i - 1]['user'] ]; } } $r[] = [ 'date' => $hist['upd'][$i]['date'], $val => $current, 'user' => $hist['upd'][$i]['user'] ]; } elseif (!empty($hist['ins'])) { $r[0] = [ 'date' => $hist['ins'][0]['date'], $val => $current, 'user' => $hist['ins'][0]['user'] ]; } } return $r; } return []; }

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.