[geeklog-devel] SQL stuff

Randy Kolenko randy at nextide.ca
Mon Nov 5 15:54:10 EST 2007


Correct - DB_save is translated in the MSSQL class - but again, it is an
approximation routine that does the appropriate test: 

-if a row exists then delete the row (based on its primary key, which
has to be in the REPLACE INTO syntax)
-then create a new row

My 2 cents on this issue is to not use replace into at all.  I would
also not use DB_SAVE as a replacement simply due to the fact it is not
portable sql in the long run.  It would be much cleaner to simply do an
update or insert if a row exists or does not exist respectively.

The more portable SQL GL gets into its base, the easier it will be to
port to other databases besides MSSQL.  The MSSQL support uses a variety
of techniques that SQL Server has (like UDFs and triggers, views and
stored procedures) to translate from MySQL sql statements to MSSQL
statements - knowing this, I doubt that anything with less functionality
that MSSQL will never be able to be supported in the GL core.

-randy


> To clarify: Code that calls DB_save should always be fine. 
> DB_save is translated into method calls for the current DB 
> class in use (MySQL or MS SQL) and therefore will "do the 
> right thing".
> 
> The problem is that the story class has a hard-coded REPLACE 
> INTO now (it didn't exist in 1.4.1) and if you're using MS 
> SQL, that will have to be emulated by Randy's layer.
> 
> I haven't even tried to understand the code there, so I don't 
> know if it can be easily replaced with a DB_save or if it 
> needs a combination of DELETE and INSERT.
> 
> Mike?
> 
> bye, Dirk
> 




More information about the geeklog-devel mailing list