method update documentation in bbn\Appui\Statistic

Update a statistic in the table bbn_statistics from the start of time

function(string $variant = NULL, string $start = NULL) { if ($this->check()) { if (!$variant) { $variant = 'default'; } if (!($real_start = $this->db->selectOne('bbn_statistics', 'MAX(day)', ['id_option' => $this->id_option, 'code' => $variant]))) { if ($start) { $real_start = $start; } elseif (!empty($this->ocfg['start'])) { $real_start = $this->ocfg['start']; } else { $real_start = self::ODATE; } } if (Str::isDateSql($real_start)) { $num_days = 0; $num = $this->db->count( 'bbn_statistics', [ 'id_option' => $this->id_option, 'code' => $variant ] ); $today = date('Ymd'); $last_res = null; $last_date = $real_start; $time = mktime( 12, 0, 0, (int)substr($real_start, 5, 2), (int)substr($real_start, 8, 2), (int)substr($real_start, 0, 4) ); $test = date('Ymd', $time); while ($test <= $today) { $res = $this->run($real_start); /* if ($num_days) { X::hdump($res, $this->db->getLastValues()); } else { X::hdump($res, $this->db->last(), $this->db->getLastValues()); } */ $num_days++; if (!$res) { $res = 0; } if (($res !== $last_res) || !$num) { if ($this->db->count( 'bbn_statistics', [ 'id_option' => $this->ocfg['id'], 'code' => $variant, 'day' => $real_start ] )) { $this->db->update( 'bbn_statistics', [ 'res' => $res ], [ 'id_option' => $this->ocfg['id'], 'code' => $variant, 'day' => $real_start ] ); } else { $this->db->insert( 'bbn_statistics', [ 'id_option' => $this->ocfg['id'], 'code' => $variant, 'day' => $real_start, 'res' => $res ] ); } $last_res = $res; $num++; } else { $this->db->update( 'bbn_statistics', [ 'day' => $real_start ], [ 'id_option' => $this->ocfg['id'], 'code' => $variant, 'day' => $last_date ] ); } $last_date = $real_start; $time += 24 * 3600; $real_start = date('Y-m-d', $time); $test = date('Ymd', $time); } return $num_days; } } return null; }

Update a statistic in the table bbn_statistics from the start of time 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.