forked from adamziel/mysql-sqlite-network-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.php
More file actions
34 lines (27 loc) · 1.05 KB
/
Copy pathclient.php
File metadata and controls
34 lines (27 loc) · 1.05 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
<?php
try {
$pdo = new PDO("mysql:host=127.0.0.1;dbname=test", "root", "");
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
die("Connection failed: " . $e->getMessage());
}
$result = $pdo->exec("DROP TABLE IF EXISTS wptests_users");
$result = $pdo->exec("
CREATE TABLE wptests_users (
ID bigint(20) unsigned NOT NULL auto_increment,
decimal_column DECIMAL(10,2) NOT NULL DEFAULT 0,
float_column FLOAT(10,2) NOT NULL DEFAULT 0,
enum_column ENUM('a', 'b', 'c') NOT NULL DEFAULT 'a',
date_column DATE NOT NULL DEFAULT CURRENT_DATE,
PRIMARY KEY (ID),
)
");
$result = $pdo->exec("INSERT INTO wptests_users (decimal_column, float_column, enum_column, date_column) VALUES (123.45, 678.90, 'b', '2024-02-14')");
$stmt = $pdo->prepare("SELECT * FROM wptests_users WHERE ID > :id");
$stmt->execute(['id' => 0]);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
var_dump($row);
$stmt = $pdo->prepare("SELECT * FROM wptests_users WHERE ID > :id");
$stmt->execute(['id' => 0]);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
var_dump($row);