<?php

namespace Signteer\Core\Writer;

use Plainwork\Database\Database;
use Plainwork\Database\Query;
use Signteer\Core\Database\VolunteerTable as Table;

class VolunteerWriter
{
    public $db = Database::class;

    public function create(string $title, string $email, string $phone): int
    {
        $q = $this->db->q();

        $q->insertInto(Table::NAME);
        $q->valueString(Table::COL_TITLE, $title);
        $q->valueString(Table::COL_EMAIL, $email);
        $q->valueString(Table::COL_PHONE, $phone);

        $id = $q->execute();

        return $id;
    }

    public function delete(int $id)
    {
        $q = $this->db->q();

        $q->deleteFrom(Table::NAME);
        $q->whereInt(Table::COL_ID, '=', $id);

        $q->execute();
    }
}
