|
|
|
 |
|  |
 |
Hamelin |
[Forum PHP] ...thread e post... |
24-03-2004 13:26 |
|
 |
Hamelin |
.pifferaio.magico.

Registered: Feb 2003
Posts: 662 (0.08 al dì)
Location: ..tra i monti intorno ad Hamelin..
Corso: Ingegneria Informatica
Anno: 3°
Time Online: 7 Days, 7:19:55 [...]
Status: Offline
Edit | Report | IP: Logged |
[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."
|
24-03-2004 13:26 |
|
|
|  |
 |
korn |
E' molto più semplice di quel che pensi :)
... |
24-03-2004 20:55 |
|
 |
korn |
SET FIRE!

Registered: Jun 2002
Posts: 5793 (0.69 al dì)
Location: Milano
Corso: Comunicazione Digitale
Anno: 1°! ....fuori corso :(
Time Online: 37 Days, 5:56:42 [...]
Status: Offline
Edit | Report | IP: Logged |
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.
|
24-03-2004 20:55 |
|
|
|  |
 |
Mino |
giusto per curiosita': il vbulletin (questo forum) ... |
25-03-2004 13:09 |
|
 |
Mino |
In pensione :)

Registered: Mar 2002
Posts: 2997 (0.36 al dì)
Location: Dublin!
Corso: Informatica 3ennale
Anno: Laureato :)
Time Online: 12 Days, 2:11:07: [...]
Status: Offline
Edit | Report | IP: Logged |
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
|
25-03-2004 13:09 |
|
|
|  |
 |
Hamelin |
[QUOTE][i]Originally posted by korn [/i]
... |
25-03-2004 14:34 |
|
 |
Hamelin |
.pifferaio.magico.

Registered: Feb 2003
Posts: 662 (0.08 al dì)
Location: ..tra i monti intorno ad Hamelin..
Corso: Ingegneria Informatica
Anno: 3°
Time Online: 7 Days, 7:19:55 [...]
Status: Offline
Edit | Report | IP: Logged |
Originally posted by korn
- 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 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?
__________________
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."
|
25-03-2004 14:34 |
|
|
|  |
 |
korn |
[QUOTE][i]Originally posted by Hamelin [/i]
... |
25-03-2004 15:13 |
|
 |
korn |
SET FIRE!

Registered: Jun 2002
Posts: 5793 (0.69 al dì)
Location: Milano
Corso: Comunicazione Digitale
Anno: 1°! ....fuori corso :(
Time Online: 37 Days, 5:56:42 [...]
Status: Offline
Edit | Report | IP: Logged |
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?
Macché complicazioni!
Per ottenere l'elenco dei thread usa questa:
SELECT * FROM tabella_post WHERE ID_THREAD = 0 ORDER BY ID DESC
("DESC" te li ordina dal più nuovo al più vecchio, se non metti "DESC" te li ordina dal più vecchio al più nuovo)
Per leggere un thread usa questa:
SELECT * FROM tabella_post WHERE ID = valore OR ID_THREAD = valore ORDER BY ID
(senza DESC stavolta, perché vanno in ordine cronologico ovviamente... quindi verrà prima il post iniziale e poi tutte le risposte nell'ordine in cui sono state postate)

__________________
» 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.
|
25-03-2004 15:13 |
|
|
|  |
 |
Hamelin |
C'hai raggione di brutto!! Grazie mille, korn... ... |
25-03-2004 15:17 |
|
 |
Hamelin |
.pifferaio.magico.

Registered: Feb 2003
Posts: 662 (0.08 al dì)
Location: ..tra i monti intorno ad Hamelin..
Corso: Ingegneria Informatica
Anno: 3°
Time Online: 7 Days, 7:19:55 [...]
Status: Offline
Edit | Report | IP: Logged |
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."
|
25-03-2004 15:17 |
|
|
|  |
 |
AlphaGamma |
L'ho sempre detto Korn che sei un figo! :)
... |
25-03-2004 15:36 |
|
 |
AlphaGamma |
.piano ma pieni.

Registered: Jun 2002
Posts: 6732 (0.81 al dì)
Location:
Corso: Eh?
Anno: Io cosa?
Time Online: 21 Days, 21:22:01: [...]
Status: Offline
Edit | Report | IP: Logged |
L'ho sempre detto Korn che sei un figo! 
A cosa ci serve il Vbulletin? C'è Korn... 
__________________
Attenzio', concentrazio', ritmo e VITALITÀ
|
25-03-2004 15:36 |
|
|
|  |
 |
Hamelin |
File di sessione... |
17-04-2004 13:43 |
|
 |
Hamelin |
.pifferaio.magico.

Registered: Feb 2003
Posts: 662 (0.08 al dì)
Location: ..tra i monti intorno ad Hamelin..
Corso: Ingegneria Informatica
Anno: 3°
Time Online: 7 Days, 7:19:55 [...]
Status: Offline
Edit | Report | IP: Logged |
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."
|
17-04-2004 13:43 |
|
|
|  |
 |
holylaw |
io sapevo che le sessioni venivano distrutte autom ... |
17-04-2004 14:05 |
|
 |
holylaw |
.grande:maestro.

Registered: Feb 2003
Posts: 3142 (0.39 al dì)
Location: milano
Corso: Magistrale Informatica
Anno: bella domanda
Time Online: 88 Days, 5:30:09: [...]
Status: Offline
Edit | Report | IP: Logged |
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.
|
17-04-2004 14:05 |
|
|
|  |
 |
Hamelin |
Sì, lo so... ma sul mio pc non è così!...mah... ... |
17-04-2004 14:52 |
|
 |
Hamelin |
.pifferaio.magico.

Registered: Feb 2003
Posts: 662 (0.08 al dì)
Location: ..tra i monti intorno ad Hamelin..
Corso: Ingegneria Informatica
Anno: 3°
Time Online: 7 Days, 7:19:55 [...]
Status: Offline
Edit | Report | IP: Logged |
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."
|
17-04-2004 14:52 |
|
|
|  |
 |
korn |
La sessione dovrebbe chiudersi automaticamente dop ... |
17-04-2004 15:07 |
|
 |
korn |
SET FIRE!

Registered: Jun 2002
Posts: 5793 (0.69 al dì)
Location: Milano
Corso: Comunicazione Digitale
Anno: 1°! ....fuori corso :(
Time Online: 37 Days, 5:56:42 [...]
Status: Offline
Edit | Report | IP: Logged |
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.
|
17-04-2004 15:07 |
|
|
|  |
 |
Hamelin |
Grazie korn! ... |
17-04-2004 19:11 |
|
 |
Hamelin |
.pifferaio.magico.

Registered: Feb 2003
Posts: 662 (0.08 al dì)
Location: ..tra i monti intorno ad Hamelin..
Corso: Ingegneria Informatica
Anno: 3°
Time Online: 7 Days, 7:19:55 [...]
Status: Offline
Edit | Report | IP: Logged |
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."
|
17-04-2004 19:11 |
|
|
|  |
 |
All times are GMT. The time now is 11:54. |
|
|
 |
|
 |
|
|
|  |
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
|
|
|
|
|
|