Zikula: A Flexible Open Source Content Management System
home | forum | contact us

Dizkus

Bottom
Changing the id - what is needed?
  • Posted: 26.01.2006, 22:40
     
    jediping
    rank:
    Helper 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!
  • Posted: 26.01.2006, 22:48
     
    ainigma32
    rank:
    Professional 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
  • Posted: 26.01.2006, 22:50
     
    jediping
    rank:
    Helper 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!
  • Posted: 26.01.2006, 23:11
     
    ainigma32
    rank:
    Professional Professional
    registered:
     January 2004
    Status:
    offline
    last visit:
    22.03.06
    Posts:
    958
    That's the point: you don't have to change the id of the publication.
    When a new version of the publication becomes available that will be retrieved as "the" publication.
  • Posted: 26.01.2006, 23:19
     
    jediping
    rank:
    Helper Helper
    registered:
     November 2004
    Status:
    offline
    last visit:
    12.03.07
    Posts:
    387
    Are older version of the publication still available? I guess I could use a different field for the ID, but that might present more problems than I can foresee at the moment.
  • Posted: 26.01.2006, 23:55
     
    ainigma32
    rank:
    Professional 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
  • Posted: 27.01.2006, 00:05
     
    jediping
    rank:
    Helper 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. :\
  • Posted: 27.01.2006, 00:18
     
    ainigma32
    rank:
    Professional 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 do

    Code

    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! icon_wink
  • Posted: 27.01.2006, 00:23
     
    jediping
    rank:
    Helper 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.
  • Posted: 27.01.2006, 00:28
     
    ainigma32
    rank:
    Professional Professional
    registered:
     January 2004
    Status:
    offline
    last visit:
    22.03.06
    Posts:
    958
    You're welcome.
  • Posted: 27.01.2006, 15:08
     
    rgasch
    rank:
    Steering Committee Steering Committee
    registered:
     January 2003
    Status:
    offline
    last visit:
    19.11.08
    Posts:
    567

    Quote

    I knew there had to be a downside to working in IT.

    After 15 years in the business, I can only say "welcome to the club" icon_smile

    Greetings
    --> R

Extensions Moderation

Main Menu

Extensions Database

Documentation

Development

Login

Donate to Zikula