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 79 80 81 82 83 84 85 86 87 88 89 90 91
|
<?php
try
{
$bdd = new PDO('mysql:host=localhost;charset=utf8', 'root', '',
array (PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
}
catch (exception $e)
{
die ('Erreur :'.$e->getMessage ());
}
if(isset($_POST["inscription"])){
$nom_societe = $_POST['nom_societe'];
$email_societe = $_POST['email_societe'];
$nom_societe = $_POST['nom_societe'];
}
$stmt = $bdd->prepare('SELECT COUNT(*) FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ?');
$stmt->execute(array($_POST['nom_societe']));
if ($stmt->fetchColumn() == 0) {
$creationbase = $bdd -> exec('CREATE DATABASE '.$nom_societe.'');
$insertionbase = $bdd -> exec('USE '.$nom_societe);
$creationtable = $bdd ->exec('
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
-- --------------------------------------------------------
--
-- Structure de la table `ajoute_article`
--
DROP TABLE IF EXISTS `ajoute_article`;
CREATE TABLE IF NOT EXISTS `ajoute_article` (
`id_employe` int(11) NOT NULL,
`id_article` int(11) NOT NULL,
PRIMARY KEY (`id_employe`,`id_article`),
KEY `FK_Ajoute_article_id_article` (`id_article`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Structure de la table `article`
--
DROP TABLE IF EXISTS `article`;
CREATE TABLE IF NOT EXISTS `article` (
`id_article` int(11) NOT NULL AUTO_INCREMENT,
`code_article` varchar(10) DEFAULT NULL,
`famille_article` varchar(50) DEFAULT NULL,
`type_article` varchar(2540) DEFAULT NULL,
`nom_article` varchar(50) DEFAULT NULL,
`description_article` text,
`prix_achat` decimal(25,0) DEFAULT NULL,
`marge_vente` decimal(10,0) DEFAULT NULL,
`prix_vente` decimal(25,0) DEFAULT NULL,
`unite_article` varchar(10) DEFAULT NULL,
`quantite_article` decimal(10,0) DEFAULT NULL,
`quantite_achat` decimal(25,0) DEFAULT NULL,
`fp_article` decimal(10,0) DEFAULT NULL,
`tva_article` decimal(25,0) DEFAULT NULL,
`id_famille` int(11) DEFAULT NULL,
PRIMARY KEY (`id_article`),
KEY `FK_Article_id_famille` (`id_famille`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
');
} else {
echo "la bdd existe";
}
?> |