Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Boa noite,
Estou com um sistema desenvolvido em PHP onde conta com um arquivo chamado BD.sql
Gostaria de saber algum artigo onde ensina a fazer um arquivo chamado INSTALL.php que já faz a instalação dos dados que estão no BD.sql
Obrigado
Já tenho tudo instalado! :-)
Isso nada mais é do que uma simples aplicação à parte do sistema principal onde cada "tela" executa uma sequência de queries.
A diferença é que você dificilmente vai fazer SELECT's, na grande maioria das vezes vai trabalhar com CREATE TABLE, ALTER TABLE, INSERT, UPDATE e DELETE para recriar o banco de dados e toda a estrutura necessária para funcionamento da aplicação principal de forma transparente ao usuário.
Bom dia,
Veja se este artigo lhe ajuda - http://www.w3schools.com/php/php_mysql_create.asp
Neste outro mostra como criar (banco,tabela e usuário) - http://suite101.com/article/creating-a-mysql-database-for-a-php-application-a104692
Então, eu queria saber na questão de criar inputs igual a instalação do wordpress por exemplo! Crio o banco de dados no mySQL , jogo os arquivos dentro do host e vou no navegador e digito: www.meusite.com.br/install.php
Ai eu iria preenchendo os inputs e clicava em instalar.
Existe algum tutorial pra isso?
É só você criar um formulário (install.php por exemplo), depois preenche-lo com os dados (nome banco, nome user, etc), fazer uma verificação e confirmado este procedimento você constrói o banco as tabelas e até as permissões do usuário com os exemplos que lhe passei.
Monte algo que vamos lhe guiando.
Formulário:
<form action="" method="">
Host: <input name="" type="text" size="50" /><br>
Banco de dados: <input name="" type="text" size="50" /><br>
Usuário do banco de dados: <input name="" type="text" size="50" /><br>
Senha: <input name="" type="text" size="50" />
</form>
Banco de dados.SQL
-- phpMyAdmin SQL Dump
-- version 3.4.11.1
-- http://www.phpmyadmin.net
--
-- Servidor: localhost
-- Tempo de Geração: 05/03/2013 às 21:20:57
-- Versão do Servidor: 5.5.23
-- Versão do PHP: 5.2.17
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Banco de Dados: ``
--
-- --------------------------------------------------------
--
-- Estrutura da tabela configuracoes
--
CREATE TABLE IF NOT EXISTS `configuracoes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`banner` varchar(255) NOT NULL,
`logo` varchar(255) NOT NULL,
`cor` varchar(255) NOT NULL,
`circulo` varchar(255) NOT NULL,
`mapa` varchar(255) NOT NULL,
`iframe` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
--
-- Extraindo dados da tabela configuracoes
--
INSERT INTO `configuracoes` (`id`, `banner`, `logo`, `cor`, `circulo`, `mapa`, `iframe`) VALUES
(1, '8.jpg', 'logo-1362528603-logo-1362016182-logo.png', '#b300b3', '8.png', 'on', '');
-- --------------------------------------------------------
--
-- Estrutura da tabela empresa
--
CREATE TABLE IF NOT EXISTS `empresa` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nome` varchar(255) NOT NULL,
`slogan` varchar(255) NOT NULL,
`telefone` varchar(255) NOT NULL,
`endereco` varchar(255) NOT NULL,
`horario` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`sobre` text NOT NULL,
`servicos` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
--
-- Extraindo dados da tabela empresa
--
INSERT INTO `empresa` (`id`, `nome`, `slogan`, `telefone`, `endereco`, `horario`, `email`, `sobre`, `servicos`) VALUES
(1, 'Petshop Amigos', 'A sua petshop de BH', '(62) 0000-0000', 'rua úrsula pulino, 1424 - betânia', 'Horário de funcionamento', 'lpcs007@gmail.com', '<div class="box">\r\n<h3>Passagem padrão original de Lorem Ipsum, usada desde o século XVI.</h3>\r\n<p>"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do \r\neiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad \r\nminim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip \r\nex ea commodo consequat. Duis aute irure dolor in reprehenderit in \r\nvoluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur \r\nsint occaecat cupidatat non proident, sunt in culpa qui officia deserunt\r\n mollit anim id est laborum."</p>\r\n<h3>Seção 1.10.32 de "de Finibus Bonorum et Malorum", escrita por CÃcero em 45 AC</h3>\r\n<p>"Sed ut perspiciatis unde omnis iste natus error sit voluptatem \r\naccusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab\r\n illo inventore veritatis et quasi architecto beatae vitae dicta sunt \r\nexplicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut \r\nodit aut fugit, sed quia consequuntur magni dolores eos qui ratione \r\nvoluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum \r\nquia dolor sit amet, consectetur, adipisci velit, sed quia non numquam \r\neius modi tempora incidunt ut labore et dolore magnam aliquam quaerat \r\nvoluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam \r\ncorporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur?\r\n Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse \r\nquam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo \r\nvoluptas nulla pariatur?"</p>\r\n<h3>Tradução para o inglês por H. Rackha, feita em 1914</h3>\r\n<p>"But I must explain to you how all this mistaken idea of denouncing \r\npleasure and praising pain was born and I will give you a complete \r\naccount of the system, and expound the actual teachings of the great \r\nexplorer of the truth, the master-builder of human happiness. No one \r\nrejects, dislikes, or avoids pleasure itself, because it is pleasure, \r\nbut because those who do not know how to pursue pleasure rationally \r\nencounter consequences that are extremely painful. Nor again is there \r\nanyone who loves or pursues or desires to obtain pain of itself, because\r\n it is pain, but because occasionally circumstances occur in which toil \r\nand pain can procure him some great pleasure. To take a trivial example,\r\n which of us ever undertakes laborious physical exercise, except to \r\nobtain some advantage from it? But who has any right to find fault with a\r\n man who chooses to enjoy a pleasure that has no annoying consequences, \r\nor one who avoids a pain that produces no resultant pleasure?"</p>\r\n<h3>Seção 1.10.33 de "de Finibus Bonorum et Malorum", escrita por CÃcero em 45 AC</h3>\r\n<p>"At vero eos et accusamus et iusto odio dignissimos ducimus qui \r\nblanditiis praesentium voluptatum deleniti atque corrupti quos dolores \r\net quas molestias excepturi sint occaecati cupiditate non provident, \r\nsimilique sunt in culpa qui officia deserunt mollitia animi, id est \r\nlaborum et dolorum fuga. Et harum quidem rerum facilis est et expedita \r\ndistinctio. Nam libero tempore, cum soluta nobis est eligendi optio \r\ncumque nihil impedit quo minus id quod maxime placeat facere possimus, \r\nomnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem \r\nquibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet\r\n ut et voluptates repudiandae sint et molestiae non recusandae. Itaque \r\nearum rerum hic tenetur a sapiente delectus, ut aut reiciendis \r\nvoluptatibus maiores alias consequatur aut perferendis doloribus \r\nasperiores repellat."</p>\r\n<h3>Tradução para o inglês por H. Rackha, feita em 1914</h3>\r\n<p>"On the other hand, we denounce with righteous indignation and \r\ndislike men who are so beguiled and demoralized by the charms of \r\npleasure of the moment, so blinded by desire, that they cannot foresee \r\nthe pain and trouble that are bound to ensue; and equal blame belongs to\r\n those who fail in their duty through weakness of will, which is the \r\nsame as saying through shrinking from toil and pain. These cases are \r\nperfectly simple and easy to distinguish. In a free hour, when our power\r\n of choice is untrammelled and when nothing prevents our being able to \r\ndo what we like best, every pleasure is to be welcomed and every pain \r\navoided. But in certain circumstances and owing to the claims of duty or\r\n the obligations of business it will frequently occur that pleasures \r\nhave to be repudiated and annoyances accepted. The wise man therefore \r\nalways holds in these matters to this principle of selection: he rejects\r\n pleasures to secure other greater pleasures, or else he endures pains \r\nto avoid worse pains."</p>\r\n</div>', '<div class="box">\r\n<h3>Passagem padrão original de Lorem Ipsum, usada desde o século XVI.</h3>\r\n<p>"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do \r\neiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad \r\nminim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip \r\nex ea commodo consequat. Duis aute irure dolor in reprehenderit in \r\nvoluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur \r\nsint occaecat cupidatat non proident, sunt in culpa qui officia deserunt\r\n mollit anim id est laborum."</p>\r\n<h3>Seção 1.10.32 de "de Finibus Bonorum et Malorum", escrita por CÃcero em 45 AC</h3>\r\n<p>"Sed ut perspiciatis unde omnis iste natus error sit voluptatem \r\naccusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab\r\n illo inventore veritatis et quasi architecto beatae vitae dicta sunt \r\nexplicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut \r\nodit aut fugit, sed quia consequuntur magni dolores eos qui ratione \r\nvoluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum \r\nquia dolor sit amet, consectetur, adipisci velit, sed quia non numquam \r\neius modi tempora incidunt ut labore et dolore magnam aliquam quaerat \r\nvoluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam \r\ncorporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur?\r\n Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse \r\nquam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo \r\nvoluptas nulla pariatur?"</p>\r\n<h3>Tradução para o inglês por H. Rackha, feita em 1914</h3>\r\n<p>"But I must explain to you how all this mistaken idea of denouncing \r\npleasure and praising pain was born and I will give you a complete \r\naccount of the system, and expound the actual teachings of the great \r\nexplorer of the truth, the master-builder of human happiness. No one \r\nrejects, dislikes, or avoids pleasure itself, because it is pleasure, \r\nbut because those who do not know how to pursue pleasure rationally \r\nencounter consequences that are extremely painful. Nor again is there \r\nanyone who loves or pursues or desires to obtain pain of itself, because\r\n it is pain, but because occasionally circumstances occur in which toil \r\nand pain can procure him some great pleasure. To take a trivial example,\r\n which of us ever undertakes laborious physical exercise, except to \r\nobtain some advantage from it? But who has any right to find fault with a\r\n man who chooses to enjoy a pleasure that has no annoying consequences, \r\nor one who avoids a pain that produces no resultant pleasure?"</p>\r\n<h3>Seção 1.10.33 de "de Finibus Bonorum et Malorum", escrita por CÃcero em 45 AC</h3>\r\n<p>"At vero eos et accusamus et iusto odio dignissimos ducimus qui \r\nblanditiis praesentium voluptatum deleniti atque corrupti quos dolores \r\net quas molestias excepturi sint occaecati cupiditate non provident, \r\nsimilique sunt in culpa qui officia deserunt mollitia animi, id est \r\nlaborum et dolorum fuga. Et harum quidem rerum facilis est et expedita \r\ndistinctio. Nam libero tempore, cum soluta nobis est eligendi optio \r\ncumque nihil impedit quo minus id quod maxime placeat facere possimus, \r\nomnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem \r\nquibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet\r\n ut et voluptates repudiandae sint et molestiae non recusandae. Itaque \r\nearum rerum hic tenetur a sapiente delectus, ut aut reiciendis \r\nvoluptatibus maiores alias consequatur aut perferendis doloribus \r\nasperiores repellat."</p>\r\n<h3>Tradução para o inglês por H. Rackha, feita em 1914</h3>\r\n<p>"On the other hand, we denounce with righteous indignation and \r\ndislike men who are so beguiled and demoralized by the charms of \r\npleasure of the moment, so blinded by desire, that they cannot foresee \r\nthe pain and trouble that are bound to ensue; and equal blame belongs to\r\n those who fail in their duty through weakness of will, which is the \r\nsame as saying through shrinking from toil and pain. These cases are \r\nperfectly simple and easy to distinguish. In a free hour, when our power\r\n of choice is untrammelled and when nothing prevents our being able to \r\ndo what we like best, every pleasure is to be welcomed and every pain \r\navoided. But in certain circumstances and owing to the claims of duty or\r\n the obligations of business it will frequently occur that pleasures \r\nhave to be repudiated and annoyances accepted. The wise man therefore \r\nalways holds in these matters to this principle of selection: he rejects\r\n pleasures to secure other greater pleasures, or else he endures pains \r\nto avoid worse pains."</p>\r\n</div>');
-- --------------------------------------------------------
--
-- Estrutura da tabela fotos
--
CREATE TABLE IF NOT EXISTS `fotos` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`imagem` varchar(255) NOT NULL,
`titulo` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ;
-- --------------------------------------------------------
--
-- Estrutura da tabela usuario
--
CREATE TABLE IF NOT EXISTS `usuario` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nome` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`usuario` varchar(255) NOT NULL,
`senha` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
--
-- Extraindo dados da tabela usuario
--
INSERT INTO `usuario` (`id`, `nome`, `email`, `usuario`, `senha`) VALUES
(1, 'Nome', 'email@email.com', 'admin', 'admin');
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Config.php
<?php
$host = 'localhost';
$user = 'root';
$senha = '';
$banco = 'nomedobanco';
$conexao = mysql_connect($host,$user,$senha) or die (mysql_error());
mysql_select_db($banco,$conexao);
?>
Bom, o que eu tenho é isso! Agora como faço pra juntar tudo? rsrs
Obrigado!
Olá amigo.
Você poderia fazer o seguinte:
Na sua página Config.php, abaixo da instrução mysql_select_db( ... ), criar uma variável que vai ter a instrução sql para realizar a criação/alteração de suas estruturas do banco de dados.
Exemplo.
<?php
$host = 'localhost';
$user = 'root';
$senha = '';
$banco = 'nomedobanco';
$conexao = mysql_connect($host,$user,$senha) or die (mysql_error());
mysql_select_db($banco,$conexao);
$exe = "CREATE TABLE IF NOT EXISTS `configuracoes` ( `id` int(11) NOT NULL AUTO_INCREMENT, `banner` varchar(255) NOT NULL, `logo` varchar(255) NOT NULL, `cor` varchar(255) NOT NULL, `circulo` varchar(255) NOT NULL, `mapa` varchar(255) NOT NULL, `iframe` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;";
mysql_query( $exe );
.
.
.
mysql_close($conexao);
?>
Conseguiu entender a idéia?
Até a próxima. :thumbsup:
primeiro vc precisa intalar o apache e o mysql, depois rodar esse instal no navegador.