来源:http://trac.seagullproject.org/wiki/Howto/DB/MaxDB

在SGL中使用MaxDB

我通过封装DB为PEAR-0dbc-Driverp写了一个叫做maxdb_SGL的类,马上就可以用了……

MaxDB的保留字

Reserved in !MaxDBContext of usage in !MaxDB!MySQL counterpart
@May prefix identifier, like '@table'Not allowed
ADDDATE()SQL functionADDDATE(); new in !MySQL version 4.1.1
ADDTIME()SQL functionADDTIME(); new in !MySQL version 4.1.1
ALPHASQL functionNothing comparable
ARRAYData typeNot implemented
ASCII()SQL function ASCII(), but implemented with a different meaning
AUTOCOMMITTransactions; ON by defaultTransactions; OFF by default
BOOLEANColumn types; BOOLEAN accepts as values only TRUE, FALSE,and NULLBOOLEAN was added in !MySQL version 4.1.0; it is a synonym for BOOL which is mapped to TINYINT(1). It accepts integer values in the same range as TINYINT as well as NULL. TRUE and FALSE can be used as aliases for 1 and 0.
CHECKCHECK TABLECHECK TABLE; similar, but not identical usage
COLUMNColumn typesCOLUMN; noise word
CHAR()SQL functionCHAR(); identical syntax; similar, not identical usage
COMMITImplicit commits of transactions happen when data definition queries are being issuedImplicit commits of transactions happen when data definition queries are being issued, but also with a number of other queries
COSH()SQL functionNothing comparable
COT()SQL functionCOT(); identical syntax and implementation
CREATESQL, data definition languageCREATE
DATABASESQL functionDATABASE(); DATABASE is used in a different context, for example CREATE DATABASE
DATE()SQL functionCURRENT_DATE
DATEDIFF()SQL functionDATEDIFF(); new in !MySQL version 4.1.1
DAY()SQL functionNothing comparable
DAYOFWEEK()SQL functionDAYOFWEEK(); the first day (1) by default is Monday in MaxDB, and Sunday in !MySQL
DISTINCTSQL functions AVG, MAX, MIN, SUMDISTINCT; but used in a different context: SELECT DISTINCT ROP inter alia in DROP INDEX DROP INDEX; similar, but not identical usage
EBCDIC()SQL functionNothing comparable
EXPAND()SQL functionNothing comparable
EXPLAINOptimizationEXPLAIN; similar, but not identical usage
FIXED()SQL functionNothing comparable
FLOAT()SQL functionNothing comparable
HEX()SQL functionHEX(); similar, but not identical usage
INDEX()SQL functionINSTR() or LOCATE(); similar, but not identical syntaxes and meanings
INDEXUSE INDEX, IGNORE INDEX and similar hints are being used right after SELECT, like SELECT … USE INDEXUSE INDEX, IGNORE INDEX and similar hints are being used in the FROM clause of a SELECT query, like in SELECTBR… FROM … USE INDEX
INITCAP()SQL functionNothing comparable
LENGTH()SQL functionLENGTH(); identical syntax, but slightly different implementation
LFILL()SQL function Nothing comparable
LIKEComparisonsLIKE; but the extended LIKE MaxDB provides rather resembles the !MySQL REGEX
LIKE wildcardsMaxDB supports '%', '_', 'ctrl+underline', 'ctrl+up arrow', '*', and '?' as wildcards in a LIKE comparison!MySQL supports '%', and '_' as wildcards in a LIKE comparison
LPAD()SQL functionLPAD(); slightly different implementation
LTRIM()SQL functionLTRIM(); slightly different implementation
MAKEDATE()SQL functionMAKEDATE(); new in !MySQL version 4.1.1
MAKETIME()SQL functionMAKETIME(); new in !MySQL version 4.1.1
MAPCHAR()SQL functionNothing comparable
MICROSECOND()SQL functionMICROSECOND(); new in !MySQL version 4.1.1
NOROUND()SQL functionNothing comparable
NULLColumn types; comparisonsNULL; MaxDB supports special NULL values that are returned by arithmetic operations that lead to an overflow or a division by zero; !MySQL does not support such special values
PISQL functionPI(); identical syntax and implementation, but parantheses are mandatory
REFData typeNothing comparable
RFILL()SQL functionNothing comparable
ROWNOPredicate in WHERE clauseSimilar to LIMIT clause
RPAD()SQL functionRPAD(); slightly different implementation
RTRIM()SQL functionRTRIM(); slightly different implementation
SEQUENCECREATE SEQUENCE, DROP SEQUENCEAUTO_INCREMENT; similar concept, but differing implementation
SINH()SQL functionNothing comparable
SOUNDS()SQL functionSOUNDEX(); slightly different syntax
STATISTICSUPDATE STATISTICS ANALYZE; similar concept, but differing implementation
SUBSTR()SQL functionSUBSTRING(); slightly different implementation
SUBTIME()SQL functionSUBTIME(); new in !MySQL version 4.1.1
SYNONYMData definition language: CREATE [PUBLIC] SYNONYM, RENAME SYNONYM,DROP SYNONYMNothing comparable
TANH()SQL functionNothing comparable
TIME()SQL functionCURRENT_TIME
TIMEDIFF()SQL functionTIMEDIFF(); new in !MySQL version 4.1.1
TIMESTAMP()SQL functionTIMESTAMP(); new in !MySQL version 4.1.1
TIMESTAMP()as argument to DAYOFMONTH() and DAYOFYEAR()SQL functionNothing comparable
TIMEZONE()SQL functionNothing comparable
TRANSACTION()Returns the ID of the current transactionNothing comparable
TRANSLATE()SQL functionREPLACE(); identical syntax and implementation
TRIM()SQL functionTRIM(); slightly different implementation
TRUNC()SQL functionTRUNCATE(); slightly different syntax and implementation
USE!MySQL commandline user interface commandUSE
USERSQL functionUSER(); identical syntax, but slightly different implementation, and parantheses are mandatory
UTC_DIFF()SQL functionUTC_DATE(); provides a means to calculate the result of UTC_DIFF()
VALUE()SQL function, alias for COALESCE()COALESCE(); identical syntax and implementation
VARIANCE()SQL functionNothing comparable
WEEKOFYEAR()SQL functionWEEKOFYEAR(); new in !MySQL version 4.1.1

修改SGL DB 库文件 (OLD)

如果你要想要使用所有的PEAR对象,你必须修改SGL_DB::singleton()函数。因为对象变量是以大写返回而SGL使用小写变量名称。

将下列这行插到设置数据存取模式的后面:

$conn->setFetchMode(DB_FETCHMODE_OBJECT);
$conn->setFetchMode('portability', DB_PORTABILITY_LOWERCASE);

这个选项已经测试在MySQL,PostgreSQL和MaxDB中正常工作。

如果需要的话,更多的PEAR文档信息请看这里

Next Step (OLD)

You have to replace all COALESCE-Functions in the SQL-Statements with the VALUE-Function, because VALUE() is the alias for COALESCE().

 
howto/db/maxdb.txt · 最后更改: 2010/05/30 00:21 (外部编辑)
 
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2