Delfins Posted June 18, 2008 Report Share Posted June 18, 2008 ttsbegin/ttscommit ir vispareizākā pieeja. Pārējie varianti var vnk mistiski nobrukt, pat ja kods 100% pareizs (mem-līki, out-of-memory un t.t. brīnumi) ja izmanto vēl try/catch tad vispār pa smuko. try { mysql_begin php_func_inserti_1() ... php_func_inserti_N() mysql_commit } catch .. { mysql_rollback } Link to comment Share on other sites More sharing options...
nemec Posted June 18, 2008 Report Share Posted June 18, 2008 klez un andrisp dzesham_no_mysql($id), a ja šitais neizpildās, tad atkal problēmas Link to comment Share on other sites More sharing options...
Val Posted June 18, 2008 Report Share Posted June 18, 2008 jebkurā gadījumā var dabūt problēmas :) Link to comment Share on other sites More sharing options...
Maaren Posted June 18, 2008 Author Report Share Posted June 18, 2008 (edited) mazlet pielabojam ...if (izpildaas_query1()) { $id = mysql_query_id(); if (izpildaam_query2()) { echo "viss bumbaas"; }else { dzesham_no_mysql($id); echo "galiigi garaam"; } }else echo 'query1 failed ..'; Klez, es zinu, es tieshi taa pat izdariju.. Laikam taa arii buus jaatstaaj, nav ko galvu lauziit.. $sqlactivatesuccesfull=mysql_query("insert into userlist(user,password,mail,sex,level,name,surname) values('$username','$dbpass','$mail','$sex','1','$firstname','$surname')"); if($sqlactivatesuccesfull){ $sqlunactivedelete = mysql_query("delete from inactive_user WHERE id='$inactiveid'"); if($sqlunactivedelete){ echo('viss ok!'); } } kas tās tāda transakcijas ir? Edited June 18, 2008 by Maaren Link to comment Share on other sites More sharing options...
Kristabs Posted June 20, 2008 Report Share Posted June 20, 2008 Man rodas jautājums, kāpēc glabāt neaktīvos lietotājus atsevišķā tabulā, ja var tajā pašā ielikt kolonu `active` = `true`/`false`? Tad nebūtu šis liekais sekss.. Link to comment Share on other sites More sharing options...
fr3akX Posted July 2, 2008 Report Share Posted July 2, 2008 Maaren, kādu storage engine izmanto tabulām, 'show table status' to paraadīs zem Type? Cik lielas tev ir tabulas, ja downtime nav kritisks, tad var alterot tabulas uz InnoDB un lietot transakcijas. Ja neizpildās visi no query'jiem, tad transakcija rollback'ojas. Tavā gadījumā transakcijas ir vissaprātīgākais variants :) BEGIN insert into userlist(user,password,mail,sex,level,name,surname) values('$username','$dbpass','$mail','$sex','1','$firstname','$surname') delete * from inactive_user WHERE id='$inactiveid COMMIT Link to comment Share on other sites More sharing options...
Gints Plivna Posted July 5, 2008 Report Share Posted July 5, 2008 kas tās tāda transakcijas ir? Skat transakcijas šeit. Gints Plivna http://datubazes.wordpress.com Link to comment Share on other sites More sharing options...
Recommended Posts