mirror of
https://github.com/OPSnet/Gazelle.git
synced 2026-01-16 18:04:34 -05:00
26 lines
683 B
PHP
26 lines
683 B
PHP
<?php
|
|
|
|
namespace Gazelle\Manager;
|
|
|
|
class Counter {
|
|
use \Gazelle\Pg;
|
|
|
|
public function create(string $name, string $description, int $value = 0): \Gazelle\Counter {
|
|
$this->pg()->prepared_query("
|
|
insert into counter
|
|
(name, description, value)
|
|
values (?, ?, ?)
|
|
", $name, $description, $value
|
|
);
|
|
return $this->find($name);
|
|
}
|
|
|
|
public function find(string $name): ?\Gazelle\Counter {
|
|
$counter = $this->pg()->scalar("
|
|
select name from counter where name = ?
|
|
", $name
|
|
);
|
|
return $counter ? new \Gazelle\Counter($counter) : null;
|
|
}
|
|
}
|