Fork me on GitHub

Block that shows when database was last updated...  Bottom

  • Something I would like to see is a block that would display the last time the database was updated. I'd like to have a "Last Modified" date displayed on my page, but since the real activity happens in the database and not the site files, the usual functions that display the last time a file was changed don't really provide much detail. Even a chunk of code that I could place in the footer would be useful.

    This is one of the requirements of the CMS that will be chosen for my group to move forward with.

    Has anyone seen anything like this or have any ideas on how to go about making something new?
  • Spire,

    This is something that sounds trivial until you actually sit and think about it for a bit. At which point this becomes something that I don't believe there's a simple solution for regardless of which CMS you talk about especially when mysql is used as the backend.

    I've had a quick look through the docs for adodb, mysql and PHP's mysql functions and there appears to be no way get the last database update. Even if there was you've got the sessions table which is updated on every page load with your last access time.

    If mysql wasn't the backend then you'd have the option of stored procedures that could be used to track insert's to tables other than the sessions table. It would probably be possible to subclass adodb to keep track of the same but would require coding. A further solution could be a PostNuke hook module (providing create and update hook methods) but this would be a little hit and miss with 3rd party modules since they don't all call hooks.

    In short there's no simple solution to this. There's nothing like a GetLastDBUpdate function for mysql. I think you'll struggle to find a generic CMS that cleanly implements this feature. Some may but I guess they'll be tied to a specific database engine (say one with stored procedures) or won't be as modular as PN.

    -Mark

    --
    Visit My homepage and Zikula themes.
  • I expected something like this, Mark. I thought about the sessions table, and know that would be a problem, but I guessed (with nothing to back it up) that you could omit tables in the function.

    What about the SHOW TABLE STATUS statement? I know it produces a lot more info, but surely it would be possible to parse the results somehow, get the dates for each table and determine which was the most recent and output that one? Again, my PHP is more theoretical in knowledge rather than practical at this point, so maybe I'm off base here.

    If not, then my answer to the higher ups is a simple one.
  • That's something i'd missed but the problem here is that it's a table operation. While you could take the relevant data from this query the problem would be which table are you going to operate on? If your site was heavily news orientated then you might run this on the stories table. If your content comes from a mix of modules you've more work to do. Don't forget that every query performed adds the load on the database and thus increases the time required to create the page.

    Picking up on one other point in your original post I wouldn't necessarily create the solution as a block. Personally i'd write the code as a Xanthia theme plugin and add it to the bottom of the theme. This way your not wasting an entire blocks worth of page real estate.

    -Mark

    --
    Visit My homepage and Zikula themes.
  • Thanks for all the tips Mark. I am out of here for two weeks now (driving down to the Maritime provinces) and will pick this up again when I return.
  • Couldn't you write a wrapper for pnADODB that checks for inserts to certain tables and then updates a PN variable that could then be queried by his display code?
  • Kind of... this was my initial thought as well. ADODB isn't a object orientated as it looks on the surface. I've looked at exactly this type of setup as i'd like to push all $dbconn->Execute functions through CacheExecute to allow for central caching of queries based on a module var for the module. Unfortunately there seems to be just enough function based code in there to make this harder than it should be.

    -Mark

    --
    Visit My homepage and Zikula themes.
  • Yeah, but in reality all PHP object code is really just functions. :)

    So, there ought to be a way, even if it's a little difficult.
  • Of course there are but the difficulty is one that's maintainable over a period of time. Most people can hack code to achieve a specific end goal at a given time. Doing that such that you create a more generic solution that can handle upgrades and other changes isn't quite as easy. As I say i'm looking for a specific solution in this area myself so may have something shortly that's consistent with both adodb and PN and allows for each upgrades and maintainence of the codebase.

    -Mark

    --
    Visit My homepage and Zikula themes.
  • There's no such thing as a temporary fix. :)

This list is based on users active over the last 60 minutes.