-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopendb.php
More file actions
23 lines (18 loc) · 828 Bytes
/
opendb.php
File metadata and controls
23 lines (18 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
// Подключаемся к базе
$sqlConnection = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db($dbname);
// Проверяем есть ли таблица статистики в нашей базе: Если нет - создаем
$chechQuery = "SELECT id FROM statistic";
$chechResult = mysql_query($chechQuery);
if(empty($chechResult)) {
$newTable = "CREATE TABLE IF NOT EXISTS `statistic` (
`id` int(6) NOT NULL AUTO_INCREMENT,
`key` varchar(255) NOT NULL,
`filename` varchar(255) NOT NULL,
`authorname` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
mysql_query($newTable);
// echo "Create Table";
}