SQL terugdraaien

Installatie lukt niet? Plotseling een foutmelding. Of weet je niet hoe iets werkt. Problemen met phpBB2 kun je in dit archief opzoeken.
Forumregels

Sinds 1 januari 2009 wordt phpBB2 niet meer ondersteund.
Onderstaande informatie is verouderd en dient uitsluitend als archief.
phpBB2.0.x
Gesloten
Erulezz
Berichten: 660
Lid geworden op: 04 jan 2004, 17:19

SQL terugdraaien

Bericht door Erulezz » 01 mei 2004, 21:02

Ik moest een DB update doen , dit stond in de Databaseupdate.php:

Code: Selecteer alles

<?
#########################################################
## SQL commands to phpBB2
## Author: Niels Chr. Rød
## Nickname: Niels Chr. Denmark
## Email: ncr@db9.dk
##
## Ver 1.0.8
##
## phpBB2 database update script for mods
## this file is intended to use with phpBB2, when installing mods
## after so you may delete this file, but only admin can use so it really doesen't matter
## The script will look what prefix you are using, and use the existing DB defined by congig.php
## The execution of this script's included SQL is harmless, so you can run it as meny times you like
## note, though that the users last visit, will be set back to his/her last login, 
## but that is a minor cosmetic isue, that will correct it self next time the use  logs in
##
## the following example are from my mods, and you can add some self, for other mods if you like
## you will after execution get a list over those commands that are run with succes and those with warnings !
## delete the sample lines if you are using it only for other mods
##
#########################################################

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'includes/functions_selects.'.$phpEx);

###################################################################################################
##
## put the SQL commands below here, the SQL commands listed below are only exampels, substitude them with the one you need ##
##
###################################################################################################
$sql=array(
'ALTER TABLE '.USERS_TABLE.' ADD user_lastlogon INT (11) DEFAULT "0" not null',
'UPDATE '.USERS_TABLE.' SET user_lastlogon=user_lastvisit WHERE user_lastlogon="0"',
'INSERT INTO '.CONFIG_TABLE.' (config_name, config_value) VALUES ("hidde_last_logon", "0")',
'ALTER TABLE ' . USERS_TABLE .' ADD user_totaltime INT (11) DEFAULT "0"',
'ALTER TABLE ' . USERS_TABLE .' ADD user_totallogon INT (11) DEFAULT "0"',
'ALTER TABLE ' . USERS_TABLE .' ADD user_totalpages INT (11) DEFAULT "0"',
'UPDATE '. USERS_TABLE .' SET user_totaltime=(user_session_time-user_lastlogon) WHERE user_totaltime="0" AND user_lastlogon>0',
'UPDATE '. USERS_TABLE .' SET user_totallogon=1 WHERE user_totallogon="0" AND user_session_time<>"0"'
);


$mods = array ( 
'Last Visit PART 1 Mod','Last Visit PART 1 Mod','Last Visit PART 2 Mod','Last Visit PART 4 Mod','Last Visit PART 4 Mod','Last Visit PART 4 Mod','Last Visit PART 4 Mod','Last Visit PART 4 Mod'
);

############################################### Do not change anything below this line #######################################

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//

if ($userdata['user_level']!=ADMIN)
      message_die(GENERAL_ERROR, "You are not Authorised to do this"); 
$n=0;
$message="<b>This list is a result of the SQL queries needed for MOD</b><br/><br/>";
while($sql[$n])
{
	$message .= ($mods[$n-1] != $mods[$n]) ? '<p><b><font size=3>'.$mods[$n].'</font></b><br/>' : '';
	if(!$result = $db->sql_query($sql[$n])) 
	$message .= '<b><font color=#FF0000>[Already added]</font></b> line: '.($n+1).' , '.$sql[$n].'<br />';
	else $message .='<b><font color=#0000fF>[Added/Updated]</font></b> line: '.($n+1).' , '.$sql[$n].'<br />';
	$n++;
}
 message_die(GENERAL_MESSAGE, $message); 
?>
Hoe moet ik het terugdraaien?

Gebruikersavatar
CG bandicoot
Berichten: 391
Lid geworden op: 18 mar 2004, 17:47
Locatie: Amersfoort
Contacteer:

Bericht door CG bandicoot » 01 mei 2004, 21:15

Wat bedoel je nou precies?

Als je bedoelt dat je al wat files hebt hebt bewerkt maar toch wilt stoppen moet je de instrucite file(meestal install.txt) openen en dan de codes die je erin hebt gezet opsporen weghalen.

Maar ik snap het nu al. Als je de SQL weer terug wil draaien moet je de tabbellen die met die mod te maken hebben verwijderen.

Code: Selecteer alles

<?
$sql = mysql_query("SELECT * FROM bestevanbeste WHERE name = 'CG Bandicoot'");
while ($obj = mysql_fetch_assoc($sql)) {
if (mysql_num_rows($sql) == 0) {
echo 'Huh?';
} else {
echo 'Als je het maar weet.';
}} ?>

Donny_nl
Berichten: 463
Lid geworden op: 27 feb 2004, 13:55
Locatie: Rotterdam
Contacteer:

Bericht door Donny_nl » 01 mei 2004, 22:04

Goed advies van CG bandicoot!!! Maar eerst even een backup maken Erulezz!

En dan nu advies dat hopelijk minder drastisch is:

in phpmyadmin ga je naar de tabel met de users (phpbb_users) en verwijder daar in de structuur de velden die je hierboven hebt aangemaakt:

user_lastlogon
user_totaltime
user_totallogon
user_totalpages

WEL DUS EERST EEN DB BACKUP MAKEN EN VOORAL GEEN TABELLEN VERWIJDEREN!
Wil je Poker leren spelen?
SQL leren?

Gebruikersavatar
mosymuis
Berichten: 6940
Lid geworden op: 05 feb 2003, 14:00
Locatie: Amsterdam
Contacteer:

Bericht door mosymuis » 01 mei 2004, 22:52

De aangepaste waardes in phpbb_users kan je niet zomaar meer herstellen, de nieuwe kolommen en rij in config wel;

Code: Selecteer alles

ALTER TABLE phpbb_users DROP user_lastlogon;
ALTER TABLE phpbb_users DROP user_totaltime;
ALTER TABLE phpbb_users DROP user_totallogon;
ALTER TABLE phpbb_users DROP user_totalpages;
DELETE FROM phpbb_config WHERE config_name = 'hidde_last_logon';

Donny_nl
Berichten: 463
Lid geworden op: 27 feb 2004, 13:55
Locatie: Rotterdam
Contacteer:

Bericht door Donny_nl » 02 mei 2004, 11:34

De aangepaste waarden die in de mod hierboven staan zijn gemaakt in de nieuwe kolommen. Dus het verwijderen van de kolommen is het enige dat moet gebeuren om de SQL opdrachten terug te draaien.
Wil je Poker leren spelen?
SQL leren?

Gebruikersavatar
mosymuis
Berichten: 6940
Lid geworden op: 05 feb 2003, 14:00
Locatie: Amsterdam
Contacteer:

Bericht door mosymuis » 02 mei 2004, 12:33

donny_nl schreef:De aangepaste waarden die in de mod hierboven staan zijn gemaakt in de nieuwe kolommen.
Ehm,

Code: Selecteer alles

'UPDATE '.USERS_TABLE.' SET user_lastlogon=user_lastvisit WHERE user_lastlogon="0"',
'INSERT INTO '.CONFIG_TABLE.' (config_name, config_value) VALUES ("hidde_last_logon", "0")',
'UPDATE '. USERS_TABLE .' SET user_totaltime=(user_session_time-user_lastlogon) WHERE user_totaltime="0" AND user_lastlogon>0',
'UPDATE '. USERS_TABLE .' SET user_totallogon=1 WHERE user_totallogon="0" AND user_session_time<>"0"'
Hoe noem je dit dan?

Donny_nl
Berichten: 463
Lid geworden op: 27 feb 2004, 13:55
Locatie: Rotterdam
Contacteer:

Bericht door Donny_nl » 02 mei 2004, 15:36

:d

Die updates hebben alleen betrekking op de kolommen die met de alter tables zijn aangemaakt. De Insert in de Config tabel kun je ook weer verwijderen, maar dat hoef ik jou toch niet uit te leggen.
Wil je Poker leren spelen?
SQL leren?

Gebruikersavatar
mosymuis
Berichten: 6940
Lid geworden op: 05 feb 2003, 14:00
Locatie: Amsterdam
Contacteer:

Bericht door mosymuis » 02 mei 2004, 15:38

Dat die updates sloegen op de nieuwe kolommen had ik niet gezien, de nieuwe rij in config had ik in de query hierboven^^ al laten verwijderen. :)

Gesloten