-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.php
More file actions
52 lines (43 loc) · 1.13 KB
/
cli.php
File metadata and controls
52 lines (43 loc) · 1.13 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/*
$driver = 'mysql';
$config = http_build_query(data: [
'host' => 'localhost',
'port' => 3306,
'dbname' => 'phpiggy'
], arg_separator:';');
$dsn = "{$driver}:{$config}";
$username = 'root';
$password = '';
try {
$db = new PDO($dsn, $username, $password);
} catch (PDOException $e) {
die("Unable to connect to database");
}
*/
include __DIR__ . '/src/Framework/Database.php';
use Framework\Database;
$db = new Database('mysql', [
'host' => 'localhost',
'port' => 3306,
'dbname' => 'phpiggy'
], 'root', '');
/*
try {
$db -> connection -> beginTransaction();
$db ->connection->query("INSERT INTO products VALUES(99, 'Gloves')");
$search = "Hats";
$query = "SELECT FROM * products WHERE name =: name";
$stmt = $db -> connection -> prepare($query);
$stmt->bindValue('name', $search, PDO::PARAM_STR);
$stmt ->execute();
var_dump($stmt->fetchAll(PDO::FETCH_OBJ));
} catch (Exception $error) {
if ($db -> connection -> inTransaction) {
$db -> connection -> rollBack();
}
echo "Transaction failed!";
}
*/
$sqlFile = file_get_contents("./database.sql");
$db->query($sqlFile);