[geeklog-devel] SQL stuff
randy at nextide.ca
Mon Nov 5 08:04:48 EST 2007
I did some more digging last night in the Replace INTO approximation for
SQL server support.
As it turns out, the DB_Save routine is the only area that does a
REPLACE INTO approximation.
So in essence, leaving the Replace into in the stories area will not
work for sql server.
In Fact, I do not recommend even using DB_SAVE to replace the replace
into statements as it is an approximation. We should really be sticking
to standard SQL (portable SQL). Using the proper UPDATES or INSERTS is
the proper way to resolve this.
> > #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.
> All REPLACE INTO statements should be converted. I made every attempt
> in the MS SQL implementation to translate those Replace Into
> with the appropriate syntax for SQL Server. However it is obviously
> more efficient to *not* go through a syntax and conversion
> process - so
> the REPLACE INTO should be, well, replaced!
> > # 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.
> I threw the warning in there during development of the class since, at
> that point, the fetching was not working 100% properly and the only
> resolution at that time was to include the link identifier. You no
> longer need to include the link identifiers to fetch the last
> insert ID.
> Actually, my big warning message can be removed if you'd like.
> geeklog-devel mailing list
> geeklog-devel at lists.geeklog.net
More information about the geeklog-devel