ODBC 数据库链接函数库Word文件下载.docx
- 文档编号:8215349
- 上传时间:2023-05-10
- 格式:DOCX
- 页数:12
- 大小:19.73KB
ODBC 数据库链接函数库Word文件下载.docx
《ODBC 数据库链接函数库Word文件下载.docx》由会员分享,可在线阅读,更多相关《ODBC 数据库链接函数库Word文件下载.docx(12页珍藏版)》请在冰点文库上搜索。
取得返回一列。
odbc_field_name:
取得字段名称。
odbc_field_type:
取得字段资料类型。
odbc_field_len:
取得字段资料长度。
odbc_free_result:
释出返回资料的内存。
odbc_longreadlen:
配置返回栏的最大值。
odbc_num_fields:
取得字段数目。
odbc_pconnect:
长期链接至ODBC数据库。
odbc_prepare:
预置SQL指令。
odbc_num_rows:
取得返回列数目。
odbc_result:
取得返回资料。
odbc_result_all:
返回HTML表格资料。
odbc_rollback:
撤消当前交易。
odbc_setoption:
调整ODBC配置。
odbc_autocommit
开关自动改动功能。
语法:
intodbc_autocommit(intconnection_id,int[OnOff]);
返回值:
整数
函数种类:
数据库功能
内容说明:
本函数用来打开或关闭自动更新(auto-commit)功能。
参数connection_id为ODBC链接的ID值。
参数OnOff可省略,表打开或关闭自动改动功能,默认值为on,欲关闭则设off。
返回值为目前的自动更新状态,若打开自动更新功能则返回true;
若关闭自动更新功能则返回false。
参考:
odbc_commit()odbc_rollback()
odbc_binmode
配置二进位资料处理方式。
intodbc_binmode(intresult_id,intmode);
本函数用来配置二进位资料返回时的处理方式。
受到本函数影响的资料类型有BINARY、VARBINARY及LONGVARBINARY。
参数result_id为返回的ID值,若设为0,则程序将配置一个新的ID值。
参数mode为配置的二进位处理方式,有下列的值
ODBC_BINMODE_PASSTHRU返回二进位资料
ODBC_BINMODE_RETURN转成十六进位返回
ODBC_BINMODE_CONVERT转成字符串资料返回
注意:
若使用odbc_fetch_into(),ODBC_BINMODE_PASSTHRU会导至返回字符串值都是空的(empty)。
而返回资料最大治募默认大小为4096位组,若要返回更多的资料需使用odbc_longreadlen()。
odbc_fetch_into()odbc_longreadlen()
odbc_close<
关闭ODBC链接。
语法:
voidodbc_close(intconnection_id);
无
本函数用来关闭与ODBC数据库之间的链接。
参数connection_id为ODBC链接代号ID值。
若正在执行transactions则无法关闭链接。
odbc_close_all
关闭所有ODBC链接。
voidodbc_close_all(void);
本函数用来关闭与ODBC数据库之间所有的链接。
和odbc_close()一样,若正在执行transactions则无法关闭链接。
使用本函数不需要使用任何参数。
odbc_commit
改动ODBC数据库。
intodbc_commit(intconnection_id);
本函数用来改动(commit)ODBC数据库。
参数connection_id为ODBC链接的ID值。
若有配置odbc_autocommit()成自动改动数据库时,则不需使用本函数。
odbc_connect
链接至ODBC数据库。
intodbc_connect(stringdsn,stringuser,stringpassword,int[cursor_type]);
数据库功能
内容说明:
本函数用来链接到ODBC数据库,返回值为链接的代号ID值。
参数dsn为资料来源名称(DataSourcesName)。
参数user及password分别为链接的帐号及密码。
参数cursor_type通常省略,其值有SQL_CUR_USE_IF_NEEDED、SQL_CUR_USE_ODBC、SQL_CUR_USE_DRIVER及SQL_CUR_DEFAULT等四种。
当使用复杂的资料存取时可能会有类似"
Cannotopenacursoronastoredprocedurethathasanythingotherthanasingleselectstatementinit"
的错误信息字符串,此时若将参数cursor_type的值设为SQL_CUR_USE_ODBC就可以避开了。
odbc_pconnect()
odbc_cursor
取得游标名。
stringodbc_cursor(intresult_id);
字符串
本函数用来取得打开的ODBC数据库游标(cursor)。
参数connection_id为ODBC链接代号ID值。
返回值为游标的名称字符串。
odbc_do
执行SQL指令。
intodbc_do(intconnection_id,stringquery);
整数<
数据库功能
内容说明:
本函数用来执行SQL的query指令。
参数connection_id为ODBC链接代号ID值。
参数query则为欲执行的指令。
返回值为ResultID值。
odbc_prepare()odbc_execute()odbc_exec()
odbc_exec
intodbc_exec(intconnection_id,stringquery);
函数种类:
参数connection_id为ODBC链接代号ID值。
返回值为ResultID值。
odbc_prepare()odbc_execute()odbc_do()
odbc_execute
执行预置SQL指令。
intodbc_execute(intresult_id,array[parameters_array]);
本函数用来执行预置在4.36.20odbc_prepare()的query指令。
参数result_id为ODBC返回ID值。
参数parameters_array通常省略。
使用范例
<
?
php
$conn=odbc_connect(&
quot;
mydb"
"
"
&
);
$stmt=odbc_prepare($conn,"
INSERTINTOmytable(jor_from,jor_to)VALUES('
$from'
'
$to'
if(!
odbc_execute($stmt)){echo&
quot;
错误"
;
}
odbc_close($conn);
>
odbc_prepare()odbc_exec()odbc_do()
odbc_fetch_into<
取得返回的指定列。
intodbc_fetch_into(intresult_id,int[rownumber],arrayresult_array);
本函数用来取得Query的返回资料列,并放入数组资料之中。
参数result_id为ODBC返回ID值。
参数rownumber为指定的取得列(row)。
数组参数result_array为取得列的资料数组,通常在前面加上"
&
;
符号。
例如vbhunt@silverfox.com所提供的范例(27-Sep-1998)
$cols=odbc_fetch_into($QueryID,$RowNum,&
$YourArray);
odbc_fetch_row
取得返回一列。
intodbc_fetch_row(intresult_id,int[row_number]);
本函数用来取得Query的返回资料的一列。
参数rownumber可省略,为指定的取得列(row)。
$conn=odbc_connect("
WebDB"
"
&
$query="
selectuser,idno"
;
$query.="
fromuserinfo"
$result_id=odbc_do($conn,$query);
while(odbc_fatch_row($result_id)){
$user=odbc_result($result_id,1);
$idno=odbc_result($result_id,2);
echo$user."
的身份证字号为"
.$idno."
br>
\n"
odbc_close($conn);
odbc_field_name
取得字段名称。
语法:
stringodbc_fieldname(intresult_id,intfield_number);
内容说明:
本函数用来取得Query的返回资料的字段名称。
参数result_id为ODBC返回ID值。
参数field_number为指定的字段,起始值为1。
odbc_field_type
取得字段资料类型。
stringodbc_field_type(intresult_id,intfield_number);
本函数用来取得Query的返回资料的字段资料类型。
参数result_id为ODBC返回ID值。
参数field_number为指定的字段,起始值为1。
odbc_field_len
取得字段资料长度。
intodbc_field_len(intresult_id,intfield_number);
本函数用来取得Query的返回资料的字段资料长度。
参数field_number为指定的字段,起始值为1。
odbc_free_result
释出返回资料的内存。
intodbc_free_result(intresult_id);
本函数可用来释出返回资料所使用的内存,通常在系统内存资源不足的情形下才需要使用。
参数result_id为ODBC返回ID值。
返回值永远都是true。
odbc_longreadlen<
配置返回栏的最大值。
intodbc_longreadlen(intresult_id,intlength);
本函数用来配置返回资料栏的最大资料值。
参数length即为欲配置的长度值,本参数若设为0,表示不限长度。
odbc_num_fields
取得字段数目。
intodbc_num_fields(intresult_id);
返回值:
数据库功能
本函数用来取得返回资料的字段数目。
若发生错误则返回-1。
odbc_pconnect<
长期链接至ODBC数据库。
intodbc_pconnect(stringdsn,stringuser,stringpassword,int[cursor_type]);
本函数用来保持长期链接链接到ODBC数据库,即使PHP程序结束,链接仍然存在,返回值为链接的代号ID值。
这对链接负责很重的系统可以加快链接的速度。
参数dsn为资料来源名称(DataSourcesName)。
参数user及password分别为链接的帐号及密码。
参数cursor_type通常省略。
odbc_connect()odbc_prepare
预置SQL指令。
intodbc_prepare(intconnection_id,stringquery_string);
本函数用来配置SQLquery指令。
参数result_id为ODBC返回ID值。
参数query_string即为预设的指令。
odbc_execute()odbc_num_rows<
取得返回列数目。
intodbc_num_rows(intresult_id);
函数种类:
本函数用来取得返回列的数目。
若有错误发生则返回-1。
odbc_result
取得返回资料。
stringodbc_result(intresult_id,mixedfield);
本函数用来取得返回的资料。
参数field可以是数字类型,代表指定的字段序号(从1开始);
亦可以是字符串类型,为指定的字段名称。
odbc_result_all
返回HTML表格资料。
intodbc_result_all(intresult_id,string[format]);
本函数用来将取得的资料转成HTML的表格(table)格式。
参数format可省略,为表格的特殊配置值。
返回值为资料列数。
$conn=odbc_connect(&
quot;
selectitem,price"
fromuserinfo"
$result_id=odbc_do($conn,$query);
odbc_result_all($result_id,"
border=1width=50%"
odbc_rollback
撤消当前交易。
intodbc_rollback(intconnection_id);
整数
本函数取消ODBC交易处理(transaction)对数据库所做的修改。
若成功则返回true,反之返回false。
odbc_setoption
调整ODBC配置。
intodbc_setoption(intid,intfunction,intoption,intparam);
本函数用来调整ODBC的配置值。
参数id不一定指connection_id,SQLSetConnectOption()则为connection_id;
若为SQLSetStmtOption()则为result_id。
参数function值为1表SQLSetConnectOption();
若为2则为SQLSetStmtOption()。
参数option为配置的选项。
参数param为配置值。
使用范例<
//例一:
配置为autocommit,即与odbc_autocommit($conn,true)相同。
//第三个参数值102表SQL_AUTOCOMMIT。
//第四个参数值1表SQL_AUTOCOMMIT_ON。
odbc_setoption($conn,1,102,1);
//例二:
配置查询时间
//第三个参数0表SQL_QUERY_TIMEOUT
//第四个参数为最久执行时间,本例设为30秒
$result=odbc_prepare($conn,$sql);
odbc_setoption($result,2,0,30);
odbc_execute($result);
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- ODBC 数据库链接函数库 数据库 链接 函数库