Beberlei\Metrics\Collector\DoctrineDBAL::flush PHP Method

flush() public method

public flush ( )
    public function flush()
    {
        if (!$this->data) {
            return;
        }
        try {
            $this->conn->beginTransaction();
            $stmt = $this->conn->prepare('INSERT INTO metrics (metric, measurement, created) VALUES (?, ?, ?)');
            foreach ($this->data as $measurement) {
                $stmt->bindParam(1, $measurement[0]);
                $stmt->bindParam(2, $measurement[1]);
                $stmt->bindParam(3, $measurement[2]);
                $stmt->execute();
            }
            $this->conn->commit();
        } catch (Exception $e) {
            $this->conn->rollback();
        }
        $this->data = array();
    }