Skip to content

Commit

Permalink
update install ways
Browse files Browse the repository at this point in the history
  • Loading branch information
domen111 committed Apr 14, 2015
1 parent 6ae7bf2 commit a0575a1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
15 changes: 12 additions & 3 deletions install/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@
}

require_once("../system.php");
$sql = file_get_contents("./install.sql");
$db = createPDO();

$dbconf = $config["DB"];
$tablepre = $dbconf["tablepre"];
$charset = $dbconf["charset"];

ob_start();
require("install.sql");
$sql = ob_get_contents();
ob_end_clean();

$db = PDO_prepare($sql);
try{
$db->exec($sql);
$db->execute();
echo "success\n";
}catch(PDOException $e){
echo "SQL ERROR \n";
Expand Down
16 changes: 14 additions & 2 deletions install/install.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
CREATE TABLE `account` (
<?php
# This file will be required in "install.php", so you can use php code here.
if(!defined("IN_SYSTEM"))
die("Access Denied");
?>

CREATE TABLE `<?=$tablepre?>account` (
`id` int AUTO_INCREMENT,
`account` varchar(30) NOT NULL UNIQUE,
`password` varchar(30) NOT NULL,
`email` varchar(255) NOT NULL UNIQUE,
`nickname` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM CHARSET=utf8
) ENGINE=MyISAM CHARSET=<?=$charset?>;

CREATE TABLE `<?=$tablepre?>session` (
`id` int,
`expire` timestamp,
`cookie` varchar(32)
) ENGINE=MyISAM CHARSET=<?=$charset?>;

0 comments on commit a0575a1

Please sign in to comment.