| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) exit; |
| 4 |
if (!class_exists('BVLogger')) : |
| 5 |
class BVLogger { |
| 6 |
public $db; |
| 7 |
public $table; |
| 8 |
const MAXROWCOUNT = 100000; |
| 9 |
|
| 10 |
function __construct($db, $table) { |
| 11 |
$this->db = $db; |
| 12 |
$this->table = $table; |
| 13 |
} |
| 14 |
|
| 15 |
public function log($data) { |
| 16 |
if (is_array($data)) { |
| 17 |
$tablename = $this->db->getBVTable($this->table); |
| 18 |
if ($this->db->rowsCount($tablename) > BVLogger::MAXROWCOUNT) |
| 19 |
$this->db->deleteRowsFromtable($this->table, 1); |
| 20 |
$this->db->replaceIntoBVTable($this->table, $data); |
| 21 |
} |
| 22 |
} |
| 23 |
} |
| 24 |
endif; |