-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.php
More file actions
28 lines (26 loc) · 998 Bytes
/
Copy pathinstall.php
File metadata and controls
28 lines (26 loc) · 998 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
27
28
<?php
require_once "./db.php";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "start sql...";
// sql to create table
$sql .= "DROP TABLE IF EXISTS `ejson_content`;";
$sql .= "CREATE TABLE `ejson_content` ( `id` int(11) NOT NULL COMMENT 'id', `json` text NOT NULL COMMENT 'json value') ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
$sql .= "INSERT INTO `ejson_content` (`id`, `json`) VALUES (1, '{}'), (2, 'a3fa');";
$sql .= "ALTER TABLE `ejson_content` ADD PRIMARY KEY (`id`);";
$sql .= "ALTER TABLE `ejson_content` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id', AUTO_INCREMENT=3; COMMIT;";
$conn->exec($sql);
echo "<br>";
echo "<br>";
echo "Mysql data install successfully!";
echo "<br>";
echo "<br>";
echo "Rename install.php or delete it.";
}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
$conn = null;
?>