Precedente :: Successivo |
Autore |
Messaggio |
Estevan Utente adolescente


Registrato: 28/12/03 21:12 Messaggi: 310 Residenza: Sant'imbų Al d'emagna
|
Inviato: Mar Gen 18, 2005 3:26 pm Oggetto: Query multiple con PHP + MYSQL |
|
|
ciao a tutti,
sto provando a scrivere una transazione con mysql e se la gestisco direttamente da mysql tutto funziona correttamente, mwentre appena copio la stringa in php, non mi funziona.
Ho scoperto che non mi gestisce le query multiple e allora la eseguo una ad una ma perdo la transazione.
non c'č un modo per eseguire query multiple!!!
PS ricordo che il db funziona con query multiple ma php no!!!!
bo ciao cive |
|
Top |
|
 |
abaddon Utente adulto


Registrato: 05/04/04 16:32 Messaggi: 2033
|
Inviato: Mar Gen 18, 2005 6:24 pm Oggetto: |
|
|
Zio Pino m'ha suggerito questo:
Citazione: |
Regarding transactions, you must use a recent MySQL version which supports InnoDB tables. you should read the mysql manual (the part about Innodb tables, section 7.5) and configure your server to use them.
Some reading about how it works:
http://php.weblogs.com/discuss/msgReader$1446?mode=topic
(Click where it says Part2, I can't put the direct URL here because it is too long)
Then in PHP you use commands like:
mysql_query("BEGIN");
mysql_query("COMMIT");
mysql_query("ROLLBACK");
You must make sure that you convert your existing tables to innodb or create new ones: CREATE TABLE (...) type=innodb; |
|
|
Top |
|
 |
vinz Amministratore


Registrato: 12/12/03 12:56 Messaggi: 6648 Residenza: San Pellegrino Terme (Bergamo)
|
Inviato: Mar Gen 18, 2005 8:13 pm Oggetto: |
|
|
abaddon, mi hai preceduto.
Estefan, se non dichiari esplicitamente l'inizio di una transazione, lui assume ogni tua istruzione SQL come tra BEGIN e COMMIT. _________________ Let the future tell the truth and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I really worked, is mine.
Nikola Tesla |
|
Top |
|
 |
Estevan Utente adolescente


Registrato: 28/12/03 21:12 Messaggi: 310 Residenza: Sant'imbų Al d'emagna
|
Inviato: Mer Gen 19, 2005 8:35 pm Oggetto: |
|
|
Ok avete ragione non mi sono spiegato....
Questa query viene passata a mysql tramite il control center e funziona
start transaction;
insert into articolo values(i suoi valori);
update fattura set (.....);
commit;
cosė funziona
poi mettendola in php....
// passatemi la pseudo sintassi
$query = "start transaction;
insert into articolo values(i suoi valori);
update fattura set (.....);
commit;"
mysql_query($query , $connection);
cosė mi da errore perchč nella stringa $query ci sono + query.
se la spezzetto come abadon
//////////////////////////////////
mysql_query("BEGIN");
mysql_query("COMMIT");
mysql_query("ROLLBACK");
-----------------------------------
allora funziona, ma io volevo farla nel mio modo.
Sapete come fare???? |
|
Top |
|
 |
vinz Amministratore


Registrato: 12/12/03 12:56 Messaggi: 6648 Residenza: San Pellegrino Terme (Bergamo)
|
Inviato: Mer Gen 19, 2005 8:41 pm Oggetto: |
|
|
Ragazzo, posta l'errore!  _________________ Let the future tell the truth and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I really worked, is mine.
Nikola Tesla |
|
Top |
|
 |
|