.dsy:it.
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)


Posted by Hamelin on 24-03-2004 13:26:

Question [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."


Posted by korn on 24-03-2004 20:55:

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.


Posted by Napolux on 25-03-2004 12:57:

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).


:sbav:

Questa idea non mi sarebbe mai venuta in 5000 anni... :D

Korn, ti devo frequentare piu' spesso :asd:

__________________
Napolux.com


Posted by Mino on 25-03-2004 13:09:

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


Posted by Hamelin on 25-03-2004 14:34:

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."


Posted by korn on 25-03-2004 15:13:

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.


Posted by Hamelin on 25-03-2004 15:17:

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."


Posted by AlphaGamma on 25-03-2004 15:36:

L'ho sempre detto Korn che sei un figo! :)
A cosa ci serve il Vbulletin? C'è Korn... :D

__________________
Attenzio', concentrazio', ritmo e VITALITÀ


Posted by Hamelin on 17-04-2004 13:43:

Question 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... :asd: )...

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."


Posted by holylaw on 17-04-2004 14:05:

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.


Posted by Hamelin on 17-04-2004 14:52:

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."


Posted by korn on 17-04-2004 15:07:

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.


Posted by Hamelin on 17-04-2004 19:11:

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.