ManaPHP\Meter\Linear::_save PHP Метод

_save() защищенный Метод

protected _save ( string $type, string $id, integer $count ) : void
$type string
$id string
$count integer
Результат void
    protected function _save($type, $id, $count)
    {
        /**
         * @var \ManaPHP\Meter\Linear\Model $model
         * @var \ManaPHP\Meter\Linear\Model $instance
         */
        $hash = md5($type . ':' . $id);
        $model = new $this->_model();
        $r = $model::updateAll(['count' => $count], ['hash' => $hash]);
        if ($r === 0) {
            $instance = new $this->_model();
            $instance->hash = $hash;
            $instance->type = $type;
            $instance->id = $id;
            $instance->count = $count;
            $instance->created_time = time();
            try {
                $instance->create();
            } catch (\Exception $e) {
                $model::updateAll(['count' => $count], ['hash' => $hash]);
            }
        }
    }