Le titre est un peu tordu , mais voilà ce que je voudrais faire.
En fait, j'ai un petit script qui tourne avec une base de donnée temporaire (chaque exécution du script vide d'abord une des tables avant de procéder au reste).
Le script permet de modifier une autre table.
Je voudrais faire une fonction de restauration de configuration par défaut.
J'i un export de la base de données fait par phpmyadmin.
Je voudrais utiliser le script de cet export pour le mettre dans la page php qui exécuterait cette restauration par défaut, mais évidement, si je colle le contenu du fichier export.sql , et que je lance la page, ca ne marche pas.
Voici mon code :
Code : Tout sélectionner
<html>
<head>
<title>Calcul des défauts - Configuration</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<LINK rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<HR size=2 align=center width="100%"></HR>
<table class=tab2 width="100%" valign="top" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="left"><img src="config.png" width="50" height="50"></td>
<td align="right"><a href="./"><img src="back.png" width="50" height="50"></a></td>
</tr>
</table>
<HR size=2 align=center width="100%"></HR>
<?
$objConnect = mysql_connect("localhost","injections","injections") or die(mysql_error()); // Conect to MySQL
$objDB = mysql_select_db("injections");
-- phpMyAdmin SQL Dump
-- version 3.5.1
-- http://www.phpmyadmin.net
--
-- Client: localhost
-- Généré le: Mer 05 Octobre 2016 à 00:57
-- Version du serveur: 5.5.24-log
-- Version de PHP: 5.3.13
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 */;
--
-- Base de données: `injections`
--
-- --------------------------------------------------------
--
-- Structure de la table `inj_config`
--
DROP TABLE IF EXISTS `inj_config`;
CREATE TABLE IF NOT EXISTS `inj_config` (
`id` int(4) NOT NULL AUTO_INCREMENT,
`inj_delay` time NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `priority` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
--
-- Contenu de la table `inj_config`
--
INSERT INTO `inj_config` (`id`, `inj_delay`) VALUES
(1, '00:10:00');
-- --------------------------------------------------------
--
-- Structure de la table `inj_deftype`
--
DROP TABLE IF EXISTS `inj_deftype`;
CREATE TABLE IF NOT EXISTS `inj_deftype` (
`type_id` tinyint(2) NOT NULL,
`type_name` varchar(128) NOT NULL,
`type_disp` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`type_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Contenu de la table `inj_deftype`
--
INSERT INTO `inj_deftype` (`type_id`, `type_name`, `type_disp`) VALUES
(1, 'Balance Erreur, Erreur cellule photoélectrique', 1),
(2, 'Balance Résultat, Article trop long', 1),
(3, 'Balance Résultat, Plusieurs articles sur la bande de la balance', 1),
(4, 'Injection Arrêtée avec présence d\\''articles', 1),
(5, 'Injection Colis égaré Bande 7', 1),
(6, 'Injection Colis égaré Bande 8', 1),
(7, 'Injection Colis trop large', 1),
(8, 'Injection Colis trop long/large', 1),
(9, 'Injection Erreur cellule photoélectrique Bande 8 PEC 8,1', 1),
(10, 'Injection', 1);
-- --------------------------------------------------------
--
-- Structure de la table `inj_eqpt`
--
DROP TABLE IF EXISTS `inj_eqpt`;
CREATE TABLE IF NOT EXISTS `inj_eqpt` (
`eqpt_id` tinyint(2) NOT NULL,
`eqpt_name` varchar(16) NOT NULL,
`eqpt_color` varchar(6) NOT NULL,
PRIMARY KEY (`eqpt_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Contenu de la table `inj_eqpt`
--
INSERT INTO `inj_eqpt` (`eqpt_id`, `eqpt_name`, `eqpt_color`) VALUES
(1, 'SB01-IUB01', '82B4FF'),
(2, 'SB01-IUB02', '82B4FF'),
(3, 'SB01-IUB03', '82B4FF'),
(4, 'SB01-IUB04', '82B4FF'),
(5, 'SB01-IUB05', '82B4FF'),
(6, 'SB01-IUB06', '82B4FF'),
(7, 'SB01-IUB07', '82B4FF'),
(8, 'SH01-IUH01', 'FFE3B4'),
(9, 'SH01-IUH02', 'FFE3B4'),
(10, 'SH01-IUH03', 'FFE3B4'),
(11, 'SH01-IUH05', 'FFE3B4'),
(12, 'SH01-IUH06', 'FFE3B4'),
(13, 'SH01-IUH07', 'FFE3B4'),
(14, 'SH01-IUH08', 'FFE3B4');
-- --------------------------------------------------------
--
-- Structure de la table `inj_list`
--
DROP TABLE IF EXISTS `inj_list`;
CREATE TABLE IF NOT EXISTS `inj_list` (
`id` int(4) NOT NULL AUTO_INCREMENT,
`inj_name` varchar(60) NOT NULL,
`inj_dft` varchar(128) NOT NULL,
`inj_debut` datetime NOT NULL,
`inj_fin` datetime NOT NULL,
`inj_duree` time NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `priority` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
/*!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 */;
header("Location: manage.php?success" );
?>
</body>
</html>Y-t-il une solution permettant de reprendre le script .sql pour le faire exécuter en php sans tout modifier ?
Merciiii
Couin