Text in mySQL-DB ersetzen (unter php!)

PHP, Ajax, CSS, HTML, Javascript
Eben für die wirklich Harten, die alles selber machen.
Antworten
Benutzeravatar
oxpus
Administrator
Beiträge: 28735
Registriert: Mo 27.Jan, 2003 22:13
Wohnort: Bad Wildungen
Kontaktdaten:

Text in mySQL-DB ersetzen (unter php!)

Beitrag von oxpus »

UPDATE tabelle SET feld=replace(feld, 'ABC', 'XYZ');
tabelle = Tabelle der Datenbank
feld = Feld in der Tabelle
'ABC' = Text, der ersetzt werden soll
'XYZ' = Neuer Text, der den alten ersetzt

replace funktioniert auch bei Variablen innerhalb phpBB.
Benutzeravatar
Rabi
Beiträge: 233
Registriert: Fr 16.Sep, 2005 15:00
Wohnort: Kiel

Beitrag von Rabi »

Mal ne Verstänsnisfrage!

In meiner Datenbank habe ich neulich das ausgeführt:

Code: Alles auswählen

CREATE TABLE phpbb_refer_plus (
  rp_id mediumint(8) unsigned NOT NULL auto_increment,
  refer_id varchar(7) NOT NULL default '0',
  refer_new varchar(7) NOT NULL default '0',
  rp_time varchar(10) NOT NULL default '',
  PRIMARY KEY (rp_id)
) TYPE=MyISAM;

INSERT INTO phpbb_refer_plus VALUES (1, 2, 2, '1115859081');

CREATE TABLE phpbb_refer_top (
  rp_id mediumint(8) unsigned NOT NULL auto_increment,
  refer_id varchar(7) NOT NULL default '0',
  refer_new varchar(7) NOT NULL default '0',
  rp_time varchar(10) NOT NULL default '',
  PRIMARY KEY (rp_id)
) TYPE=MyISAM;

INSERT INTO phpbb_refer_top VALUES (1, 2, 2, '1105474506');

INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_default_id', '0' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_enable', '1' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_rtop_enable', '1' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_rewards_enable', '0' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_refer_new_posts', '5' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_posts_allowed', '1' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_gold', '1000' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_top', '10' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_time', 'Current Referrals' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_timem', 'Life Time Referrals' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_reward', 'user_gold' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_top10_list', 'Top 10 Referrals' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_top10_list_explain', 'All Time Top 10 List of Members Who Have Referred New Members.' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_life_time', '= the Number of Friends You have Referred. To Invite a Friend and Get Credits on Your Account, Please visit the:' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_now_time', '= the Total Number of Friends You have Referred During our Current Promotion.' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_top_list_enabled', '1' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_header', '1' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_invite', '1' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_email', 'We are removing members from our database that are no longer active on our forum. If you wish to keep your account active, please visit our site and your account will not be de-activated.' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_board', 'About forum.' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_invite_header', 'Invite a Friend' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_invite_friend', 'Send Emails to Invite Friends to Join this Forum.' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_top_now_list', 'Current Referrals Top 10 List of Members Who Have Referred New Members to our forum .' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_admin_id', '2' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_life_time_rc', '= the Total Number of Friends You have Referred to our forum.' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_rewards', 'Current Rewards' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_rewards_explain', '= Your Rewards Total for Referring New Members!' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_referc_header', 'Referral Center' );

Möchte dieses jetzt aber durch dieses ersetzen (deutsch):

Code: Alles auswählen

CREATE TABLE phpbb_refer_plus (
  rp_id mediumint(8) unsigned NOT NULL auto_increment,
  refer_id varchar(7) NOT NULL default '0',
  refer_new varchar(7) NOT NULL default '0',
  rp_time varchar(10) NOT NULL default '',
  PRIMARY KEY (rp_id)
) TYPE=MyISAM;

INSERT INTO phpbb_refer_plus VALUES (1, 2, 2, '1115859081');

CREATE TABLE phpbb_refer_top (
  rp_id mediumint(8) unsigned NOT NULL auto_increment,
  refer_id varchar(7) NOT NULL default '0',
  refer_new varchar(7) NOT NULL default '0',
  rp_time varchar(10) NOT NULL default '',
  PRIMARY KEY (rp_id)
) TYPE=MyISAM;

INSERT INTO phpbb_refer_top VALUES (1, 2, 2, '1105474506');

INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_default_id', '0' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_enable', '1' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_rtop_enable', '1' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_rewards_enable', '0' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_refer_new_posts', '5' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_posts_allowed', '1' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_gold', '1000' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_top', '10' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_time', 'Aktuelle Empfehlungen' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_timem', 'Life Time Empfehlungen' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_reward', 'user_gold' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_top10_list', 'Top 10 Empfehlungen' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_top10_list_explain', 'All Time Top 10 Liste der Benutzer die neue Benutuer geworben haben.' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_life_time', '= die Anzahl der Freunde die du geworben hast. Um einen Freund einzuladen und Geld zu bekommen, Besuche bitte das:' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_now_time', '= die Anzahl der Freunde die du geworben hast während unserer aktuellen Promotion.' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_top_list_enabled', '1' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_header', '1' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_invite', '1' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_email', 'Wir löschen Benutzer in unserer Datenbank die nicht im Forum aktiv sind. Wenn du dein Account aktive halten möchtest, besuche bitte unsere Seite und der Account wird nicht gelöscht.' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_board', 'Über das Forum.' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_invite_header', 'einen Freund einladen' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_invite_friend', 'Sende Emails um Freunde einzuladen sich für dieses Forum zu registrieren.' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_top_now_list', 'Aktuelle Empfehlungen Top 10 Liste von Mitgliedern, die andere Mitglieder geworben haben.' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_admin_id', '2' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_life_time_rc', '= die Anzahl der Freunde die du in unserem Forum geworben hast.' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_rewards', 'Aktuelle Belohnung' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_rewards_explain', '= Deine Gesamtbelohnung für das werben neuer Benutzer!' );
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_referc_header', 'Empfehlungs-Center' );
Muss ich das so machen wie oben beschrieben, oder gibt es da ne "überschreiben" Funktion?
Max
Beiträge: 628
Registriert: So 23.Jan, 2005 09:54

Beitrag von Max »

Hallo,

das kannst Du nicht einfach so machen, da es sonst Fehlermeldungen gäbe, die besagen, dass dort schon ein Eintrag vorliegt.

Deshalb müsste dieses hier:

Code: Alles auswählen

INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ( 'rp_referc_header', 'Empfehlungs-Center' );

so aussehen:

Code: Alles auswählen

UPDATE `phpbb_config` SET `config_value` = 'Empfehlungs-Center' WHERE (`config_name`) = 'rp_referc_header' LIMIT 1 ;

Ist übrigens nur die letzte Zeile, also alle anderen auch anpassen ;)



Gruß Max
Benutzeravatar
Rabi
Beiträge: 233
Registriert: Fr 16.Sep, 2005 15:00
Wohnort: Kiel

Beitrag von Rabi »

ok... Dann war ich schon "gedanklich" richtig! ;)

Dankeschön...
Antworten