[geeklog-devel] SQL stuff

Dirk Haun dirk at haun-online.de
Sat Nov 3 11:09:34 EDT 2007


I was actually looking into something else, but just stumbled across
these two issues:

#1: In story.class.php, we have a hard-coded REPLACE INTO (I assume it
also exists in 1.4.1 - didn't check). That, IIRC, is a MySQL extension.
Shouldn't we try and avoid these sort of things? Given that the story
class already does a lot of checks for existing IDs it looks like that
shouldn't be too hard to replace with INSERT and a DELETE, where needed.

# 2: What I was actually after is the ID generated from an INSERT. In
other words: DB_insertId().

The MS SQL implementation carries a big warning to always pass in a link
identification so that you don't accidentally get the last ID from
another connection. But all the calls to DB_insertId() that I can find
are without that identifier. And since it's stored in a class variable
anyway, you can't even pass it in from the outside.

So, shouldn't we do something like this instead?

    function dbInsertId($link_identifier = '')
    {
        if (empty($link_identifier)) { 
            return @mysql_insert_id($this->_db); // <- $this->_db added
        } else { 
            return @mysql_insert_id($link_identifier);
        }
    }

bye, Dirk


-- 
http://www.haun-online.de/
http://spam.tinyweb.net/




More information about the geeklog-devel mailing list