- Moderated by:
- Support Team
-
- rank:
-
Helper
- registered:
- November 2004
- Status:
- offline
- last visit:
- 12.03.07
- Posts:
- 387
I need to have the option for entries in my database to be resubmited. The previous entry will still be available, but a new entry with a new id will also be created. Is there a way to let any hooks and/or the cache know to look for this new id, rather than the old one? I'm going to have EZComments enabled, as well as pnUpper, at least for now. I'm not 100% sure I want to update the hooks even if it's possible, but I want to know if I even have the option before I continue.
Thanks in advance! -
- rank:
-
Professional
- registered:
- January 2004
- Status:
- offline
- last visit:
- 22.03.06
- Posts:
- 958
This sounds an awful lot like the way Pagesetter handles publications and revisions. That would mean that the comments and other hooks would point to the publication-id. If you retrieve the publication you always get the latest revision.
HTH -
- rank:
-
Helper
- registered:
- November 2004
- Status:
- offline
- last visit:
- 12.03.07
- Posts:
- 387
Possibly, though I haven't used Pagesetter, so I don't know if they ever change the ID of a publication after it's been created.
*sigh* I really wish I didn't have to do it this way, but I do. Fie upon them all! -
- rank:
-
Professional
- registered:
- January 2004
- Status:
- offline
- last visit:
- 22.03.06
- Posts:
- 958
Yes older version are available. Take the following table for example:
Code
CREATE TABLE pubs(
id INT(10) NOT null,
revision INT(10) NOT null,
content TEXT,
PRIMARY key(id, revision)
);
INSERT INTO pubs VALUES
(0, 0, 'This is a'),
(0, 1, 'This is a test'),
(0, 2, 'This is a test for revisions');
You could use the following query to retrieve the last revision:
Code
SELECT id, revision, content FROM pubs
WHERE id=0
ORDER BY id, revision DESC
LIMIT 1;
And the following query to retrieve the previous revision (I'm assuming there was a check for revisions):
Code
SELECT id, revision, content FROM pubs
WHERE id=0
ORDER BY id, revision DESC
LIMIT 1, 1;
HTH -
- rank:
-
Helper
- registered:
- November 2004
- Status:
- offline
- last visit:
- 12.03.07
- Posts:
- 387
Okay, I can see that. How does Pagesetter increment the IDs, though?
This would all probably make more sense if I didn't have a throbbing headache. :\ -
- rank:
-
Professional
- registered:
- January 2004
- Status:
- offline
- last visit:
- 22.03.06
- Posts:
- 958
I'm not sure about Pagesetter's method but there are a couple of choices. Easiest (I think) is a separate table with an auto_increment field. The id field in the pubs table would then become a foreign key. To create a new pub you doCode
INSERT INTO pub_ids(id) VALUES(null);
You take the new id that's returned using ADODB's Insert_ID( ) function and you use that to do the next query:Code
INSERT INTO pubs(id, revision, content) VALUES ($id, 0, 'The content of the publication');
If you want to create a new revision you select the latest revision-id and increment it "manually".
HTH
Go take an aspirine and stop staring at that damn computer screen!
-
- rank:
-
Helper
- registered:
- November 2004
- Status:
- offline
- last visit:
- 12.03.07
- Posts:
- 387
Hrrrmmmm. I can definitely see that. It gives me something to think about, if nothing else. Thanks for your input!
And I'll stop as soon as I'm done with work. *sigh* I knew there had to be a downside to working in IT.
