-
Notifications
You must be signed in to change notification settings - Fork 0
/
fixtures.php
78 lines (62 loc) · 2 KB
/
fixtures.php
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
require_once ("conexao.php");
echo "#### EXECUTANDO FIXTURE ####" . "<br />";
$conn = conectaDB();
echo "Removendo tabela TESTE" . "<br />";
$conn->query("DROP TABLE IF EXISTS teste;");
echo " - OK" . "<br />";
echo "Removendo tabela USUARIOS" . "<br />";
$conn->query("DROP TABLE IF EXISTS usuarios;");
echo " - OK" . "<br />";
echo "Criar tabela TESTE" . "<br />";
$conn->query("CREATE TABLE teste (
id BIGINT(20) NOT NULL AUTO_INCREMENT,
page_name text CHARACTER SET 'utf8' null,
page_content longtext CHARACTER SET 'utf8' null,
PRIMARY KEY (id));");
echo " - OK" . "<br />";
echo "Criar tabela USUARIOS" . "<br />";
$conn->query("CREATE TABLE IF NOT EXISTS `usuarios` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`nome` varchar(100) NOT NULL,
`usuario` varchar(50) NOT NULL,
`senha` varchar(50) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `usuario` (`usuario`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
echo " - OK" . "<br />";
echo "Inserindo Dados Tabela TESTE" . "<br />";
$files = array(
'empresa.php',
'servicos.php',
'produtos.php',
'contato.php',
'home.php',
'404.php',
'head.php',
'menu.php',
'footer.php',
'login.php'
);
foreach($files as $file){
$content = file_get_contents($file);
$page_name = explode('.', $file);
$smt = $conn->prepare("INSERT INTO teste (page_name, page_content) VALUES (:page_name, :page_content);");
$smt->bindValue(':page_name', $page_name[0]);
$smt->bindValue(':page_content', $content);
$smt->execute();
}
echo " - OK" . "<br />";
echo "Inserindo Dados Tabela USAURIOS" . "<br />";
$id = 1;
$nome = 'admin';
$usuario = 'admin';
$senha = 'admin';
$smt = $conn->prepare("INSERT INTO `pdo`.`usuarios` (`id`, `nome`, `usuario`, `senha`) VALUES (:id, :nome, :usuario, :senha)");
$smt->bindValue(':id', $id);
$smt->bindValue(':nome', $nome);
$smt->bindValue(':usuario', $usuario);
$smt->bindValue(':senha', $senha);
$smt->execute();
echo " - OK" . "<br />";
echo "### CONCLUIDO ####" . "<br />";