![]() |
Show 150 posts per page |
.dsy:it. (http://www.dsy.it/forum/)
- Tech (http://www.dsy.it/forum/forumdisplay.php?forumid=189)
-- [Forum PHP] ...thread e post... (http://www.dsy.it/forum/showthread.php?threadid=9737)
[Forum PHP] ...thread e post...
Sto provando a costruire un forummino semplice semplice per studio sul mio pc... Apache/PHP/MySQL, ovviamente...
L'idea sarebbe un forum unico, non diviso per argomenti. Il problema è questo: ho bisogno (vero?) di avere un numero di identificazione per ogni post, ma anche un ID per sapere a quale thread il dato post appartiene... ora, se per l'ID del post basta che nella tabella inserisca un campo tipo:
INT (4) UNSIGNED auto_increment not null
(ma il not null mi serve in questo caso?), per l'ID del thread (chiamiamolo così) come faccio?: faccio una seconda tabella? Con che campi? Come la concilio con la prima? HELP!!!
__________________
Bjarne Stroustrup: "I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone."
Andrew S. Tanenbaum: "Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway."
Edsger Dijkstra: "Computer Science is no more about computers than astronomy is about telescopes."
Robert Firth: "One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs."
Donald Knuth: "A mathematical formula should never be 'owned' by anybody! Mathematics belong to God."
E' molto più semplice di quel che pensi
Io farei così:
Crea un campo ID_THREAD di tipo INT in cui:
- se il valore è 0 significa che quel post è l'inizio di un thread
- se il valore non è 0 significa che quel post è una risposta ad un thread il cui ID è il valore stesso
Per ordinare correttamente la sequenza dei thread e dei post ti consiglieri di utilizzare un campo contenente un timestamp unix, ma con l'ID auto_increment in teoria basterebbe ordinarli per ID per avere la sequenza corretta (teoricamente non dovrebbe riutilizzare come ID eventuali valori di post cancellati, cosa che invece creerebbe dei problemi di ordinamento).
__________________
» Collect some stars to shine for you, and start today ‘cause there are only a few. _ (In Flames)
» Don't stop for nothing, it's full speed or nothing! I'm taking down, you know, whatever is in my way! _ ('tallica)
» I am my own god, I do as I please. _ (Pain)
» Ninetynine, ninetynine knives! Ninetynine knives inside! Nobody gets out alive! _ (The Haunted)
Web: http://www.negativesignal.com - ICQ# 171585477 - Death to software patents! And TCPA too! "e uno!", diceva il boia.
Originally posted by korn
E' molto più semplice di quel che pensi![]()
Io farei così:
Crea un campo ID_THREAD di tipo INT in cui:
- se il valore è 0 significa che quel post è l'inizio di un thread
- se il valore non è 0 significa che quel post è una risposta ad un thread il cui ID è il valore stesso
Per ordinare correttamente la sequenza dei thread e dei post ti consiglieri di utilizzare un campo contenente un timestamp unix, ma con l'ID auto_increment in teoria basterebbe ordinarli per ID per avere la sequenza corretta (teoricamente non dovrebbe riutilizzare come ID eventuali valori di post cancellati, cosa che invece creerebbe dei problemi di ordinamento).
__________________
Napolux.com
giusto per curiosita': il vbulletin (questo forum) e il phpbb utilizzano due tabelle, una per i thread e una per i post.
Quella dei thread include principalmente:
- id del thread "autoincrementativo"
- topic
- id dell'autore
- timestamp, ecc ecc
Quella dei post:
- id del post "autoincrementativo"
- id del thread a cui il post appartiene
- titolo e testo del post
- id dell'autore
- timestamp, ecc ecc
In questo modo le pagine vengono ricostruite con una join (in realta' nel vb viene fatto con una select, per motivi di prestazioni).
__________________
icq: 57553717 - mail: mino@ngi.it - web: www.minux.it - Fattori Arcani
Originally posted by kornMa poi per visualizzare il topic devo fare una query più complicata, no? Non è meglio ch'io copi anche nei post iniziali l'id_thread corrispettivo? Se uso una sola tabella non posso far altro che usare l'id del post iniziale come id del thread, nevvero?
- se il valore è 0 significa che quel post è l'inizio di un thread
- se il valore non è 0 significa che quel post è una risposta ad un thread il cui ID è il valore stesso
__________________
Bjarne Stroustrup: "I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone."
Andrew S. Tanenbaum: "Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway."
Edsger Dijkstra: "Computer Science is no more about computers than astronomy is about telescopes."
Robert Firth: "One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs."
Donald Knuth: "A mathematical formula should never be 'owned' by anybody! Mathematics belong to God."
Originally posted by Hamelin
Ma poi per visualizzare il topic devo fare una query più complicata, no? Non è meglio ch'io copi anche nei post iniziali l'id_thread corrispettivo? Se uso una sola tabella non posso far altro che usare l'id del post iniziale come id del thread, nevvero?
__________________
» Collect some stars to shine for you, and start today ‘cause there are only a few. _ (In Flames)
» Don't stop for nothing, it's full speed or nothing! I'm taking down, you know, whatever is in my way! _ ('tallica)
» I am my own god, I do as I please. _ (Pain)
» Ninetynine, ninetynine knives! Ninetynine knives inside! Nobody gets out alive! _ (The Haunted)
Web: http://www.negativesignal.com - ICQ# 171585477 - Death to software patents! And TCPA too! "e uno!", diceva il boia.
C'hai raggione di brutto!! Grazie mille, korn...
__________________
Bjarne Stroustrup: "I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone."
Andrew S. Tanenbaum: "Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway."
Edsger Dijkstra: "Computer Science is no more about computers than astronomy is about telescopes."
Robert Firth: "One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs."
Donald Knuth: "A mathematical formula should never be 'owned' by anybody! Mathematics belong to God."
L'ho sempre detto Korn che sei un figo!
A cosa ci serve il Vbulletin? C'è Korn...
__________________
Attenzio', concentrazio', ritmo e VITALITÀ
File di sessione...
Ma i file delle varie sessioni PHP vengono cancellati automaticamente dai servizi di hosting?
Chiedo perché, provando in locale, mi rimangono e intasano il mio hd (...solo qualche byte... )...
Oppure c'è un modo per usare session_destroy() quando un utente chiude il browser? (...come sarebbe possibile?)
Denghiu for anzuers...
__________________
Bjarne Stroustrup: "I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone."
Andrew S. Tanenbaum: "Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway."
Edsger Dijkstra: "Computer Science is no more about computers than astronomy is about telescopes."
Robert Firth: "One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs."
Donald Knuth: "A mathematical formula should never be 'owned' by anybody! Mathematics belong to God."
io sapevo che le sessioni venivano distrutte automaticamente quano si chiude il browser......
__________________
La mia epoca ed io non siamo fatti l'uno per l'altro:questo è chiaro. Ma è da vedere chi di noi due vincerà il processo di fronte al tribunale dei posteri.
AV MJØDEN VART DU VIS OG KLOK, SÅ DREKKA MER!!!!
Le persone sagge parlano perché hanno qualcosa da dire.
Le persone sciocche perché hanno da dire qualcosa.
Sì, lo so... ma sul mio pc non è così!...mah...
__________________
Bjarne Stroustrup: "I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone."
Andrew S. Tanenbaum: "Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway."
Edsger Dijkstra: "Computer Science is no more about computers than astronomy is about telescopes."
Robert Firth: "One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs."
Donald Knuth: "A mathematical formula should never be 'owned' by anybody! Mathematics belong to God."
La sessione dovrebbe chiudersi automaticamente dopo che è passato, dalla chiusura del browser o dall'uscita dal sito, il tempo di "timeout" impostato per gli script.
__________________
» Collect some stars to shine for you, and start today ‘cause there are only a few. _ (In Flames)
» Don't stop for nothing, it's full speed or nothing! I'm taking down, you know, whatever is in my way! _ ('tallica)
» I am my own god, I do as I please. _ (Pain)
» Ninetynine, ninetynine knives! Ninetynine knives inside! Nobody gets out alive! _ (The Haunted)
Web: http://www.negativesignal.com - ICQ# 171585477 - Death to software patents! And TCPA too! "e uno!", diceva il boia.
Grazie korn!
__________________
Bjarne Stroustrup: "I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone."
Andrew S. Tanenbaum: "Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway."
Edsger Dijkstra: "Computer Science is no more about computers than astronomy is about telescopes."
Robert Firth: "One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs."
Donald Knuth: "A mathematical formula should never be 'owned' by anybody! Mathematics belong to God."
All times are GMT. The time now is 00:49. | Show all 13 posts from this thread on one page |
Powered by: vBulletin Version 2.3.1
Copyright © Jelsoft Enterprises Limited 2000 - 2002.