|
发表于 2018-6-20 09:23:55
|
显示全部楼层
本帖最后由 onlycdh 于 2018-6-20 09:27 编辑
我后来参照sql server的写了一个类似的,基本功能可以使用
class informix{
ctor( param,...){
var connectionString;
if( type(param) == type.table ){
var tList = ..string.list(,";","=")
tList.mixin(param)
if( !tList.find("DSN") ){
if( !tList.find("Driver") ) tList.Driver ="IBM INFORMIX ODBC DRIVER";//client端是3.5
if( !tList.find("Host") ) tList["Host"]=" ";//服务器IP
if( !tList.find("Server") ) tList["Server"]="";//数据库实例
if( !tList.find("Service") ) tList["Service"]="";//端口号
if( !tList.find("Protocol")) tList["Protocol"]= "onsoctcp";
};
connectionString = tostring( tList );
}
else {
if( !param ) error("请指定数据库连接串",2)
connectionString = ..string.format( param,... );
}
var conn = ..com.CreateObject("ADODB.Connection")
conn.ConnectionString = connectionString;
var ok,err = call(conn.open,conn);
if(!ok) return null,"打开数据库连接失败:" +err;
this.connection = conn;
this._tables = {@{_weak="kv"}}
..table.gc(this,"close");
};
}
使用时
var db = informix(
["Database"] = " ";//数据库名
["Uid"]=" ";//用户名
["Pwd"]=" ";//密码
); |
|