Précédent   Forum des professionnels en informatique > PHP > PHP & SGBD > PHP & MySQL
PHP & MySQL Forum d'entraide sur les fonctions MySQL avec PHP. Avant de poster -> FAQ MySQL, Cours MySQL et Sources MySQL. Pour les questions concernant le moteur MySQL plutôt que les fonctions PHP, merci d'utiliser le forum MySQL.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 09/02/2011, 05h34   #1
Invité de passage
 
Inscription : juin 2007
Messages : 46
Détails du profil
Informations forums :
Inscription : juin 2007
Messages : 46
Points : 2
Points : 2
Par défaut Est-ce que cette requête est exacte pour créer une nouvelle table?

Bonjour,

J'ai une table qui aurait dû s'installer automatiquement à l'aide du fichier ci-dessous, mais ça n'a pas marché donc j'aimerais la créer manuellement en tapant directement une requête SQL dans phpMyAdmin.
Pourriez-vous me dire quelle partie de ce code dois-je taper dans ma requête? A moins qu'il faille entrer ce code en entier !!


Code :
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
$installer = $this;
 
$installer->run("
CREATE TABLE `{$installer->getTable('customer/form_attribute')}` (
  `form_code` char(32) NOT NULL,
  `attribute_id` smallint UNSIGNED NOT NULL,
  PRIMARY KEY(`form_code`, `attribute_id`),
  KEY `IDX_CUSTOMER_FORM_ATTRIBUTE_ATTRIBUTE` (`attribute_id`),
  CONSTRAINT `FK_CUSTOMER_FORM_ATTRIBUTE_ATTRIBUTE` FOREIGN KEY (`attribute_id`) REFERENCES `{$installer->getTable('eav_attribute')}` (`attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Customer attributes/forms relations';
");
 
$installer->getConnection()->dropColumn($installer->getTable('customer/eav_attribute'), 'is_visible_on_front');
$installer->getConnection()->changeColumn($installer->getTable('customer/eav_attribute'), 'lines_to_divide_multiline',
    'multiline_count', 'TINYINT UNSIGNED NOT NULL DEFAULT 1');
$installer->getConnection()->dropColumn($installer->getTable('customer/eav_attribute'), 'min_text_length');
$installer->getConnection()->dropColumn($installer->getTable('customer/eav_attribute'), 'max_text_length');
$installer->getConnection()->modifyColumn($installer->getTable('customer/eav_attribute'), 'input_filter',
    'varchar(255) DEFAULT NULL');
$installer->getConnection()->addColumn($installer->getTable('customer/eav_attribute'), 'validate_rules',
    'text DEFAULT NULL');
$installer->getConnection()->addColumn($installer->getTable('customer/eav_attribute'), 'is_system',
    'TINYINT UNSIGNED NOT NULL DEFAULT 0');
$installer->getConnection()->addColumn($installer->getTable('customer/eav_attribute'), 'sort_order',
    'INT UNSIGNED NOT NULL DEFAULT 0');
 
$installer->updateEntityType('customer', 'attribute_model', 'customer/attribute');
$installer->updateEntityType('customer_address', 'attribute_model', 'customer/attribute');

Merci pour votre aide.
guillaume7684 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 09/02/2011, 11h33   #2
Membre éclairé
 
Homme Jérémy
Étudiant
Inscription : octobre 2009
Messages : 236
Détails du profil
Informations personnelles :
Nom : Homme Jérémy
Localisation : France

Informations professionnelles :
Activité : Étudiant
Secteur : High Tech - Produits et services télécom et Internet

Informations forums :
Inscription : octobre 2009
Messages : 236
Points : 322
Points : 322
PhpMyAdmin n'acceptera pas ton code tels quel, celui-ci comprenant du php, tu doit entrer les valeurs à la mains pour les éléments comme "$installer->getTable"
Si tu as un message d'erreur pourrait tu nous le communiquer.
gwharl est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 09/02/2011, 14h14   #3
Invité de passage
 
Inscription : juin 2007
Messages : 46
Détails du profil
Informations forums :
Inscription : juin 2007
Messages : 46
Points : 2
Points : 2
Si je copie exactement ce code dans ma requête SQL et que j'exécute, j'ai ce message d'erreur:

Citation:
Erreur

requête SQL:

$installer = $this;

MySQL a répondu: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$installer = $this' at line 1




Par contre, si je ne mets que ce code dans ma requête SQL:
Code :
1
2
3
4
5
6
7
CREATE TABLE `{$installer->getTable('customer/form_attribute')}` (
  `form_code` char(32) NOT NULL,
  `attribute_id` smallint UNSIGNED NOT NULL,
  PRIMARY KEY(`form_code`, `attribute_id`),
  KEY `IDX_CUSTOMER_FORM_ATTRIBUTE_ATTRIBUTE` (`attribute_id`),
  CONSTRAINT `FK_CUSTOMER_FORM_ATTRIBUTE_ATTRIBUTE` FOREIGN KEY (`attribute_id`) REFERENCES `{$installer->getTable('eav_attribute')}` (`attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Customer attributes/forms relations'
J'ai ce message d'erreur:
Citation:
#1103 - Incorrect table name '{$installer->getTable('customer/form_attribute')}'

Ce que je mets comme syntaxe doit vous paraître absurde, mais je ne suis pas un pro de l'informatique!!

Merci.
guillaume7684 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 09/02/2011, 14h17   #4
Membre Expert
 
Avatar de gene69
 
Inscription : janvier 2006
Messages : 951
Détails du profil
Informations personnelles :
Localisation : France

Informations professionnelles :
Secteur : High Tech - Produits et services télécom et Internet

Informations forums :
Inscription : janvier 2006
Messages : 951
Points : 1 063
Points : 1 063
bonjour

normal, ya des variables embeded dans la chaine de la requete sql. Puisque tu es assez fort pour trifouillé regarde la syntaxe exacte de CREATE TABLE:
http://dev.mysql.com/doc/refman/5.1/...ate-table.html
__________________
PHP fait nativement la validation d'adresse électronique Vous êtes perdu en PHP? rassurez-vous ici (en)
Utilisez le bouton résolu!
gene69 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 06h11.


 
 
 
 
Partenaires

Hébergement Web