您的位置:建站学院首页 >> 文章 >> CGI技术
关于odbc的一个文挡说明
Win32::ODBC - Object
--------------------------------------------------------------------------------
Creating an ODBC Object
Your script will need to have the following line:
use Win32::ODBC;
调用模块
Then you will need to create a data connection to your DSN:
$Data = new Win32::ODBC("MyDSN");
数据源的连接
You shoud check to see if $Data is indeed defined otherwise there has been an error. You can now send SQL queries and retrieve info to your heart's content! See the description of functions below and also test.pl to see how it all works.
Make sure that you close your connection when you are finished:
$Data->Close();
关闭连接
--------------------------------------------------------------------------------
Object Methods
General Note
All methods assume that you have the line:
use Win32::ODBC;
somewhere before the method calls, and that you have an ODBC object called $db which was created using some call similar to:
$db = new Win32::ODBC("MyDSN");
See new for more information.
Also, in an effort to keep the examples short, no error checking is done on return values for any calls other than the one being exemplified. You should always check for error conditions in production code.
WARNING: The example code has not yet been tested. This will be fixed ASAP, but be forwarned!
Catalog qualifier, owner, name, type
Retrieves the catalog from the current ODBC object.
Returns a four-element array (Qualifier, Owner, Name, Type).
Note:All fieldnames are uppercase!
Example:
($qualifier, $owner, $name, $type) = $db->Catalog("", "", "%", "'TABLE'");
从库中检索数据到下面四个变量中(Qualifier, Owner, Name, Type)
Connection
Returns the object's ODBC connection number.
Example:
$cnum = $db->Connection;
建立连接
Close
Closes the ODBC connection for this object. It always returns undef.
Example: $db->Close();
断开连接
Data
Data list
Retrieve data from previous fetch for a list of field names.
In a scalar context it returns all of the field values concatenated together.
In an array context, it returns an array of the values, in the order in which they were
--------------------------------------------------------------------------------
Creating an ODBC Object
Your script will need to have the following line:
use Win32::ODBC;
调用模块
Then you will need to create a data connection to your DSN:
$Data = new Win32::ODBC("MyDSN");
数据源的连接
You shoud check to see if $Data is indeed defined otherwise there has been an error. You can now send SQL queries and retrieve info to your heart's content! See the description of functions below and also test.pl to see how it all works.
Make sure that you close your connection when you are finished:
$Data->Close();
关闭连接
--------------------------------------------------------------------------------
Object Methods
General Note
All methods assume that you have the line:
use Win32::ODBC;
somewhere before the method calls, and that you have an ODBC object called $db which was created using some call similar to:
$db = new Win32::ODBC("MyDSN");
See new for more information.
Also, in an effort to keep the examples short, no error checking is done on return values for any calls other than the one being exemplified. You should always check for error conditions in production code.
WARNING: The example code has not yet been tested. This will be fixed ASAP, but be forwarned!
Catalog qualifier, owner, name, type
Retrieves the catalog from the current ODBC object.
Returns a four-element array (Qualifier, Owner, Name, Type).
Note:All fieldnames are uppercase!
Example:
($qualifier, $owner, $name, $type) = $db->Catalog("", "", "%", "'TABLE'");
从库中检索数据到下面四个变量中(Qualifier, Owner, Name, Type)
Connection
Returns the object's ODBC connection number.
Example:
$cnum = $db->Connection;
建立连接
Close
Closes the ODBC connection for this object. It always returns undef.
Example: $db->Close();
断开连接
Data
Data list
Retrieve data from previous fetch for a list of field names.
In a scalar context it returns all of the field values concatenated together.
In an array context, it returns an array of the values, in the order in which they were