-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabase.php
More file actions
26 lines (25 loc) · 763 Bytes
/
Copy pathDatabase.php
File metadata and controls
26 lines (25 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
namespace ChouScaffolding\Database;
class Database{
public \PDO $connection;
public function __construct(\PDO $connection) {
$this->connection = $connection;
}
public function transaction($handler){
$this->connection->beginTransaction();
try {
$handler($this->connection);
$this->connection->commit();
} catch (\Throwable $th) {
$this->connection->rollback();
throw $th;
}
}
public function query(string $query,array $variable,&$affected_row = 0):\PDOStatement{
$statement = $this->connection->prepare($query);
$statement->execute($variable);
$affected_row = $statement->rowCount();
return $statement;
}
}
?>