| Total Complexity | 11 |
| Total Lines | 71 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class Database |
||
| 10 | { |
||
| 11 | use Table; |
||
| 12 | use Clause; |
||
| 13 | use Keyword; |
||
| 14 | use Operators; |
||
| 15 | use Statement; |
||
| 16 | |||
| 17 | private $conn; |
||
| 18 | private $exec; |
||
| 19 | |||
| 20 | public function connection(Driver $driver): PDO |
||
| 21 | { |
||
| 22 | return $this->conn = new PDO($driver->getDsn(), $driver->getUser(), $driver->getPass()); |
||
| 23 | } |
||
| 24 | |||
| 25 | public function prepare(): Database |
||
| 26 | { |
||
| 27 | $this->exec = $this->conn->prepare($this->getQuery()); |
||
| 28 | return $this; |
||
| 29 | } |
||
| 30 | |||
| 31 | public function bind(): Database |
||
| 38 | } |
||
| 39 | |||
| 40 | public function fetch() |
||
| 41 | { |
||
| 42 | return $this->exec->fetch(PDO::FETCH_OBJ); |
||
| 43 | } |
||
| 44 | |||
| 45 | public function fetchAll() |
||
| 46 | { |
||
| 47 | return $this->exec->fetchAll(PDO::FETCH_OBJ); |
||
| 48 | } |
||
| 49 | |||
| 50 | public function exec() |
||
| 51 | { |
||
| 52 | if ($this->exec->execute()) { |
||
| 53 | return $this->exec; |
||
| 54 | } |
||
| 55 | |||
| 56 | return null; |
||
| 57 | } |
||
| 58 | |||
| 59 | public function execute() |
||
| 60 | { |
||
| 61 | $execute = $this->prepare()->bind()->exec(); |
||
| 62 | |||
| 63 | $this->reset(); |
||
| 64 | |||
| 65 | return $execute; |
||
| 66 | } |
||
| 67 | |||
| 68 | public function getQuery(): string |
||
| 71 | } |
||
| 72 | |||
| 73 | public function reset() |
||
| 74 | { |
||
| 80 | } |
||
| 81 | } |
||
| 82 |