Rollback MySQLi/PHP

Gestart doorWouterr0 reacties60 weergaven

1 berichten · pagina 1 van 1

Wouterr

Lid · Topicstarter

Berichten
5.274
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien

Eindhoven, Nederland

Hey one2xs leden,

Ik was even aan het klooien met rollback en commit, alleen het wil niet echt werken.

Wat doe ik hier fout? De output hier is altijd test - test, terwijl de firstname voor de transaction toch echt Wouter was.

[COLOR= #0000BB]<?php
$this[/COLOR][COLOR= #007700]->[/COLOR]registry[COLOR= #007700]->[/COLOR]db[COLOR= #007700]->[/COLOR]autocommit[COLOR= #007700]([/COLOR]FALSE[COLOR= #007700]);[/COLOR]
            
[COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]registry[COLOR= #007700]->[/COLOR]db[COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]UPDATE tblclients SET firstname = "test" WHERE id = 1[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]registry[COLOR= #007700]->[/COLOR]db[COLOR= #007700]->[/COLOR]error[COLOR= #007700]);[/COLOR]
            
[COLOR= #0000BB]$checkQuery[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]registry[COLOR= #007700]->[/COLOR]db[COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]SELECT firstname FROM tblclients WHERE id = 1 LIMIT 1[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]registry[COLOR= #007700]->[/COLOR]db[COLOR= #007700]->[/COLOR]error[COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$checkFetch[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$checkQuery[/COLOR][COLOR= #007700]->[/COLOR]fetch_assoc[COLOR= #007700]();[/COLOR]
            
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$checkFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]firstname[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000] - [/COLOR][COLOR= #007700];[/COLOR]
            
[COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]registry[COLOR= #007700]->[/COLOR]db[COLOR= #007700]->[/COLOR]rollback[COLOR= #007700]();[/COLOR]
            
[COLOR= #0000BB]$checkQuery[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]registry[COLOR= #007700]->[/COLOR]db[COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]SELECT firstname FROM tblclients WHERE id = 1 LIMIT 1[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]registry[COLOR= #007700]->[/COLOR]db[COLOR= #007700]->[/COLOR]error[COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$checkFetch[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$checkQuery[/COLOR][COLOR= #007700]->[/COLOR]fetch_assoc[COLOR= #007700]();[/COLOR]
            
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$checkFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]firstname[/COLOR][COLOR= #007700]];[/COLOR]


Let aub niet op de foutafhandeling e.d, dit gaat niet voor productie oid.

Bedankt,
Wouter

toevoeging op 3 juni 2013, 12:36:03:
Nevermind, het werkt al. Gebruik nu als storage engine InnoDB. emo
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren