Delete::mountQuery()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Willry\QueryBuilder;
4
5
class Delete extends Base
6
{
7
    protected function mountQuery(): void
8
    {
9
        $this->query = "DELETE FROM {$this->entity} {$this->where}";
10
    }
11
12
    public function delete(): ?int
13
    {
14
        try {
15
            $this->mountQuery();
16
            $stmt = $this->db->prepare($this->query);
17
            QueryHelpers::bind($stmt, $this->flatBindings());
18
            $stmt->execute();
19
            return $stmt->rowCount() ?? 1;
20
        } catch (\PDOException $exception) {
21
            $this->handleError($exception);
22
        }
23
    }
24
25
}
26