nettoyer une base de données

Rechercher

nettoyer une base de données

Par 63renaud  -  5 reponses  -  Le 15/10/2010 13:48  -  Editer  - 

Bonjour

je fait mon stage chez un photographe. Je suis en télétravail, en PHP et Mysql.

je dois nettoyer une base de données trop remplie par son administrateur. je dois enlever les photos et mettre un lien à la place.

ma question: est de savoir comment faire?

je pense que: une requête SQL dans une boucle pour faire le tour de la table et peut être la fonction update pour remplacer les images par des lien.

mais je n'ai pas de point de départ pour me lancer. merci

 

Réponses apportées à cette discussion

Par Cyrano  -  Le 15/10/2010 15:12  -  Haut de page  - 

Salut,

il faudrait tenter d'être plus précis sur ce que tu veux faire exactement. Si nettoyer veut dire vider des tables, tu as la commande SQL TRUNCATE qui fonctionne fort bien, maintenant si c'est pour faire des transformations, il faudrait illustrer ta question par des exemples, d'abord de ce que tu as et ensuite de ce que tu veux obtenir en sortie.

J'ajoute que les requêtes en boucles sont à éviter, d'autant plus si le nombre de lignes à traiter est important.

 
Par 63renaud  -  Le 15/10/2010 16:50  -  Haut de page  - 

bonjour

ou j'ai beaucoup de lignes à traiter.

voici une ligne avec une image qu'il faut supprimer et mettre un lien vers la même image qui se trouve dans un dossier.

[code]

INSERT INTO `wp_btev_events` VALUES ('NOTICE', '2010-01-03 18:01:30', '/homepages/26/d239869085/htdocs/vpp/actualite/wp-content/plugins/wpg2/wpg2functions.inc', '1358', 0, '66.249.65.140', 112126, 1024, 'WPG2 ADDED G2 HEADER TO WP HEADER', '', NULL, '', 0); INSERT INTO `wp_btev_events` VALUES ('NOTICE', '2010-01-03 18:01:30', '/homepages/26/d239869085/htdocs/vpp/actualite/wp-content/plugins/wpg2/wpg2embed.inc', '1358', 0, '66.249.65.140', 112127, 1024, 'WPG2 ISDONE()', '', NULL, '', 0); INSERT INTO `wp_btev_events` VALUES ('NOTICE', '2010-01-03 18:24:31', '/homepages/26/d239869085/htdocs/vpp/actualite/wp-content/plugins/wpg2/wpg2embed.inc', '1358', 0, '67.195.112.86', 112128, 1024, 'WPG2 INITALISED G2', '', NULL, '', 0); INSERT INTO `wp_btev_events` VALUES ('NOTICE', '2010-01-03 18:24:31', '/homepages/26/d239869085/htdocs/vpp/actualite/wp-content/plugins/wpg2/wpg2embed.inc', '1358', 0, '67.195.112.86', 112129, 1024, 'WPG2 LOGGED IN WP: AS G2 GUEST', '', NULL, '', 0); INSERT INTO `wp_btev_events` VALUES ('NOTICE', '2010-01-03 18:24:31', '/homepages/26/d239869085/htdocs/vpp/actualite/wp-content/plugins/wpg2/wpg2functions.inc', '1358', 0, '67.195.112.86', 112130, 1024, 'WPG2 ADDED G2 HEADER TO WP HEADER', '', NULL, '', 0); INSERT INTO `wp_btev_events` VALUES ('NOTICE', '2010-01-03 18:24:31', '/homepages/26/d239869085/htdocs/vpp/actualite/wp-content/plugins/wpg2/wpg2embed.inc', '1358', 0, '67.195.112.86', 112131, 1024, 'WPG2 ISDONE()', '', NULL, '', 0); INSERT INTO `wp_btev_events` VALUES ('NOTICE', '2010-01-03 18:29:14', '/homepages/26/d239869085/htdocs/vpp/actualite/wp-content/plugins/wpg2/wpg2embed.inc', '1358', 0, '174.129.121.101', 112132, 1024, 'WPG2 INITALISED G2', '', NULL, '', 0); INSERT INTO `wp_btev_events` VALUES ('NOTICE', '2010-01-03 18:29:14', '/homepages/26/d239869085/htdocs/vpp/actualite/wp-content/plugins/wpg2/wpg2embed.inc', '1358', 0, '174.129.121.101', 112133, 1024, 'WPG2 LOGGED IN WP: AS G2 GUEST', '', NULL, '', 0); INSERT INTO `wp_btev_events` VALUES ('NOTICE', '2010-01-03 18:29:14', '/homepages/26/d239869085/htdocs/vpp/actualite/wp-content/plugins/wpg2/wpg2functions.inc', '1358', 0, '174.129.121.101', 112134, 1024, 'WPG2 ADDED G2 HEADER TO WP HEADER', '', NULL, '', 0); INSERT INTO `wp_btev_events` VALUES ('NOTICE', '2010-01-03 18:29:15', '/homepages/26/d239869085/htdocs/vpp/actualite/wp-content/plugins/wpg2/wpg2embed.inc', '1358', 0, '174.129.121.101', 112135, 1024, 'WPG2 ISDONE()', '', NULL, '', 0); INSERT INTO `wp_btev_events` VALUES ('NOTICE', '2010-01-03 18:58:51', '/homepages/26/d239869085/htdocs/vpp/actualite/wp-content/plugins/wpg2/wpg2embed.inc', '1358', 0, '80.14.13.217', 112136, 1024, 'WPG2 INITALISED G2', '', NULL, '', 0); INSERT INTO `wp_btev_events` VALUES ('NOTICE', '2010-01-03 18:58:51', '/homepages/26/d239869085/htdocs/vpp/actualite/wp-content/plugins/wpg2/wpg2embed.inc', '1358', 0, '80.14.13.217', 112137, 1024, 'WPG2 LOGGED IN WP: AS G2 GUEST', '', NULL, '', 0);

[/code]

Mais je ne sais pas comment reconnaitre une ligne qui comporte une image.Jen n'ai que le fichier.sl que je dois importer dans une autre base. il fait 100Mo.

Merci

 
Par Cyrano  -  Le 15/10/2010 19:13  -  Haut de page  - 

Salut,

déjà, tu aurais du mettre un tableau de données au lieu des requêtes d'insertion, ça aurait été plus clair, avec le nom des colonnes, ce serait en outre un indice supplémentaire. Et pour afficher du code, il y a un symbole dans la barre d'outils du forum. En gros, j'aurais préféré voir ceci :

+--------+---------------------+-----------------------------------------------------------------------------------------+------+---+-----------------+--------+------+-----------------------------------+--+------+--+---+|        |                     |                                                                                         |      |   |                 |        |      |                                   |  |      |  |   |+--------+---------------------+-----------------------------------------------------------------------------------------+------+---+-----------------+--------+------+-----------------------------------+--+------+--+---+| NOTICE | 2010-01-03 18:01:30 | /homepages/26/d239869085/htdocs/vpp/actualite/wp-content/plugins/wpg2/wpg2functions.inc | 1358 | 0 | 66.249.65.140   | 112126 | 1024 | WPG2 ADDED G2 HEADER TO WP HEADER |  | NULL |  | 0 || NOTICE | 2010-01-03 18:01:30 | /homepages/26/d239869085/htdocs/vpp/actualite/wp-content/plugins/wpg2/wpg2embed.inc     | 1358 | 0 | 66.249.65.140   | 112127 | 1024 | WPG2 ISDONE()                     |  | NULL |  | 0 || NOTICE | 2010-01-03 18:24:31 | /homepages/26/d239869085/htdocs/vpp/actualite/wp-content/plugins/wpg2/wpg2embed.inc     | 1358 | 0 | 67.195.112.86   | 112128 | 1024 | WPG2 INITALISED G2                |  | NULL |  | 0 || NOTICE | 2010-01-03 18:24:31 | /homepages/26/d239869085/htdocs/vpp/actualite/wp-content/plugins/wpg2/wpg2embed.inc     | 1358 | 0 | 67.195.112.86   | 112129 | 1024 | WPG2 LOGGED IN WP: AS G2 GUEST    |  | NULL |  | 0 || NOTICE | 2010-01-03 18:24:31 | /homepages/26/d239869085/htdocs/vpp/actualite/wp-content/plugins/wpg2/wpg2functions.inc | 1358 | 0 | 67.195.112.86   | 112130 | 1024 | WPG2 ADDED G2 HEADER TO WP HEADER |  | NULL |  | 0 || NOTICE | 2010-01-03 18:24:31 | /homepages/26/d239869085/htdocs/vpp/actualite/wp-content/plugins/wpg2/wpg2embed.inc     | 1358 | 0 | 67.195.112.86   | 112131 | 1024 | WPG2 ISDONE()                     |  | NULL |  | 0 || NOTICE | 2010-01-03 18:29:14 | /homepages/26/d239869085/htdocs/vpp/actualite/wp-content/plugins/wpg2/wpg2embed.inc     | 1358 | 0 | 174.129.121.101 | 112132 | 1024 | WPG2 INITALISED G2                |  | NULL |  | 0 || NOTICE | 2010-01-03 18:29:14 | /homepages/26/d239869085/htdocs/vpp/actualite/wp-content/plugins/wpg2/wpg2embed.inc     | 1358 | 0 | 174.129.121.101 | 112133 | 1024 | WPG2 LOGGED IN WP: AS G2 GUEST    |  | NULL |  | 0 || NOTICE | 2010-01-03 18:29:14 | /homepages/26/d239869085/htdocs/vpp/actualite/wp-content/plugins/wpg2/wpg2functions.inc | 1358 | 0 | 174.129.121.101 | 112134 | 1024 | WPG2 ADDED G2 HEADER TO WP HEADER |  | NULL |  | 0 || NOTICE | 2010-01-03 18:29:15 | /homepages/26/d239869085/htdocs/vpp/actualite/wp-content/plugins/wpg2/wpg2embed.inc     | 1358 | 0 | 174.129.121.101 | 112135 | 1024 | WPG2 ISDONE()                     |  | NULL |  | 0 || NOTICE | 2010-01-03 18:58:51 | /homepages/26/d239869085/htdocs/vpp/actualite/wp-content/plugins/wpg2/wpg2embed.inc     | 1358 | 0 | 80.14.13.217    | 112136 | 1024 | WPG2 INITALISED G2                |  | NULL |  | 0 || NOTICE | 2010-01-03 18:58:51 | /homepages/26/d239869085/htdocs/vpp/actualite/wp-content/plugins/wpg2/wpg2embed.inc     | 1358 | 0 | 80.14.13.217    | 112137 | 1024 | WPG2 LOGGED IN WP: AS G2 GUEST    |  | NULL |  | 0 |+--------+---------------------+-----------------------------------------------------------------------------------------+------+---+-----------------+--------+------+-----------------------------------+--+------+--+---+

 

Plus clair comme ça, non ?

Ceci dit, je n'y vois aucune image. Tout ce que je peux voir, c'est que c'est une base WordPress : décidément, les CMS me hérissent parce que beaucoup s'imaginent volontiers que c'est facile à utiliser : ce n'est pas faux, à condition toutefois de savoir coder... Enfin bon.

Je reviens quand même sur un point : mettons que j'aie vu de quoi tu pars : à quoi doit donc ressembler ce à quoi arriver ? Parce que sur cette base, je ne peux pas vraiment t'aider en quoi que ce soit...

 
Par 63renaud  -  Le 15/10/2010 21:55  -  Haut de page  - 

ok maintenant je sais tout

merci de ton aide .

je vais couper ce fichier en plusieurs fichiers, et ensuite l'importer sur la nouvelle base.

je suis d'accord avec toi pour les cms, je passe plus de temps à comprendre comment cela fonctionne que de faire le code directement.

un grand merci pour toutes tes explications.

 
Par  -  Le 20/09/2012 13:45  -  Haut de page  - 

Young administrator in the architecture industry, from the south of France, I yield @ Net affection to allotment with you my acquaintance and my discoveries in the apple of the Internet!

 

 

Ajouter une réponse à la discussion

Seuls les membres connectés sont autorisés à poster dans les forums !

Identifiez-vous
Join |  ID/MDP? |