⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbd::interbase.3

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 3
📖 第 1 页 / 共 3 页
字号:
.Vb 1\& $evh = $dbh\->func(@event_names, \*(Aqib_init_event\*(Aq);.Ve.SpCreates an event handle from a list of event names..ie n .IP """ib_wait_event""" 4.el .IP "\f(CWib_wait_event\fR" 4.IX Item "ib_wait_event".Vb 1\& $dbh\->func($evh, \*(Aqib_wait_event\*(Aq);.Ve.SpWait synchronously for particular events registered via event handle \f(CW$evh\fR.Returns a hashref containing pair(s) of posted event's name and its corresponding count,or undef on failure..ie n .IP """ib_register_callback""" 4.el .IP "\f(CWib_register_callback\fR" 4.IX Item "ib_register_callback".Vb 2\& my $cb = sub { my $posted_events = $_[0]; ++$::COUNT < 6 };\& $dbh\->func($evh, $cb, \*(Aqib_register_callback\*(Aq);\&\& sub inc_count { my $posted_events = shift; ++$::COUNT < 6 };\& $dbh\->func($evh, \e&inc_count, \*(Aqib_register_callback\*(Aq);\&\& # or anonyomus subroutine\& $dbh\->func(\&   $evh, \&   sub { my ($pe) = @_; ++$::COUNT < 6 }, \&   \*(Aqib_register_callback\*(Aq\& );.Ve.SpAssociates an event handle with an asynchronous callback. A callback will bepassed a hashref as its argument, this hashref contains pair(s) of posted event's nameand its corresponding count..SpIt is safe to call \f(CW\*(C`ib_register_callback\*(C'\fR multiple times for the same event handle. In this case, the previously registered callback will be automatically cancelled..SpIf the callback returns \s-1FALSE\s0, the registered callback will be no longer invoked, but internallyit is still there until the event handle goes out of scope (or undef-ed), or you call \&\f(CW\*(C`ib_cancel_callback\*(C'\fR to actually disassociate it from the event handle..ie n .IP """ib_cancel_callback""" 4.el .IP "\f(CWib_cancel_callback\fR" 4.IX Item "ib_cancel_callback".Vb 1\& $dbh\->func($evh, \*(Aqib_cancel_callback\*(Aq);.Ve.SpUnregister a callback from an event handle. This function has a limitation,however, that it can't be called from inside a callback. In many cases, you won'tneed this function, since when an event handle goes out of scope, its associated callback(s)will be automatically cancelled before it is cleaned up..SH "RETRIEVING FIREBIRD / INTERBASE SPECIFIC INFORMATION".IX Header "RETRIEVING FIREBIRD / INTERBASE SPECIFIC INFORMATION".ie n .IP """ib_tx_info""" 4.el .IP "\f(CWib_tx_info\fR" 4.IX Item "ib_tx_info".Vb 1\& $hash_ref = $dbh\->func(\*(Aqib_tx_info\*(Aq);.Ve.SpRetrieve information about current active transaction..ie n .IP """ib_database_info""" 4.el .IP "\f(CWib_database_info\fR" 4.IX Item "ib_database_info".Vb 2\& $hash_ref = $dbh\->func(@info, \*(Aqib_database_info\*(Aq);\& $hash_ref = $dbh\->func([@info], \*(Aqib_database_info\*(Aq);.Ve.SpRetrieve database information from current connection..ie n .IP """ib_plan""" 4.el .IP "\f(CWib_plan\fR" 4.IX Item "ib_plan".Vb 1\& $plan = $sth\->func(\*(Aqib_plan\*(Aq);.Ve.SpRetrieve query plan from a prepared \s-1SQL\s0 statement..Sp.Vb 2\& my $sth = $dbh\->prepare(\*(AqSELECT * FROM foo\*(Aq);\& print $sth\->func(\*(Aqib_plan\*(Aq); # PLAN (FOO NATURAL).Ve.SH "UNSUPPORTED SQL STATEMENTS".IX Header "UNSUPPORTED SQL STATEMENTS"Here is a list of \s-1SQL\s0 statements which can't be used. But this shouldn't be a problem, because their functionality are already provided by the \s-1DBI\s0 methods..IP "\(bu" 4\&\s-1SET\s0 \s-1TRANSACTION\s0.SpUse \f(CW\*(C`$dbh\-\*(C'\fRfunc(..., 'set_tx_param')> instead..IP "\(bu" 4\&\s-1DESCRIBE\s0.SpProvides information about columns that are retrieved by a \s-1DSQL\s0 statement,or about placeholders in a statement. This functionality is supported by thedriver, and transparent for users. Column names are available via\&\f(CW$sth\fR\->{\s-1NAME\s0} attributes..IP "\(bu" 4\&\s-1EXECUTE\s0 \s-1IMMEDIATE\s0.SpCalling \fIdo()\fR method without bind value(s) will do the same..IP "\(bu" 4\&\s-1CLOSE\s0, \s-1OPEN\s0, \s-1DECLARE\s0 \s-1CURSOR\s0.Sp\&\f(CW$sth\fR\->{CursorName} is automagically available upon executing a \*(L"\s-1SELECT\s0 .. \s-1FOR\s0\&\s-1UPDATE\s0\*(R" statement. A cursor is closed after the last \fIfetch()\fR, or by calling\&\f(CW$sth\fR\->\fIfinish()\fR..IP "\(bu" 4\&\s-1PREPARE\s0, \s-1EXECUTE\s0, \s-1FETCH\s0.SpSimilar functionalities are obtained by using \fIprepare()\fR, \fIexecute()\fR, and \&\fIfetch()\fR methods..SH "COMPATIBILITY WITH DBIx::* MODULES".IX Header "COMPATIBILITY WITH DBIx::* MODULES"\&\f(CW\*(C`DBD::InterBase\*(C'\fR is known to work with \f(CW\*(C`DBIx::Recordset\*(C'\fR 0.21, and\&\f(CW\*(C`Apache::DBI\*(C'\fR 0.87. Yuri Vasiliev <\fIyuri.vasiliev@targuscom.com\fR> reported successful usage with Apache::AuthDBI (part of \f(CW\*(C`Apache::DBI\*(C'\fR 0.87 distribution)..PPThe driver is untested with \f(CW\*(C`Apache::Session::DBI\*(C'\fR. Doesn't work with \&\f(CW\*(C`Tie::DBI\*(C'\fR. \f(CW\*(C`Tie::DBI\*(C'\fR calls \f(CW$dbh\fR\->prepare(\*(L"\s-1LISTFIELDS\s0 \f(CW$table_name\fR\*(R") on which InterBase fails to parse. I think that the call should be made within an eval block..SH "FAQ".IX Header "FAQ".Sh "Why do some operations performing positioned update and delete fail when AutoCommit is on?".IX Subsection "Why do some operations performing positioned update and delete fail when AutoCommit is on?"For example, the following code snippet fails:.PP.Vb 7\& $sth = $dbh\->prepare(\& "SELECT * FROM ORDERS WHERE user_id < 5 FOR UPDATE OF comment");\& $sth\->execute;\& while (@res = $sth\->fetchrow_array) {\&     $dbh\->do("UPDATE ORDERS SET comment = \*(AqWonderful\*(Aq WHERE \&     CURRENT OF $sth\->{CursorName}");\& }.Ve.PPWhen \fBAutoCommit is on\fR, a transaction is started within \fIprepare()\fR, andcommitted automatically after the last \fIfetch()\fR, or within \fIfinish()\fR. Within\&\fIdo()\fR, a transaction is started right before the statement is executed, andgets committed right after the statement is executed. The transaction handleis stored within the database handle. The driver is smart enough not tooverride an active transaction handle with a new one. So, if you notice thesnippet above, after the first \fIfetchrow_array()\fR, the \fIdo()\fR is still using thesame transaction context, but as soon as it has finished executing the statement, it\&\fBcommits\fR the transaction, whereas the next \fIfetchrow_array()\fR still needsthe transaction context!.PPSo the secret to make this work is \fBto keep the transaction open\fR. This can bedone in two ways:.IP "\(bu" 4Using AutoCommit = 0.SpIf yours is default to AutoCommit on, you can put the snippet within a block:.Sp.Vb 5\& {\&     $dbh\->{AutoCommit} = 0;\&     # same actions like above ....\&     $dbh\->commit;\& }.Ve.IP "\(bu" 4Using \f(CW$dbh\fR\->{ib_softcommit} = 1.SpThis driver-specific attribute is available as of version 0.30. You may wantto look at t/40cursoron.t to see it in action..Sh "Why do nested statement handles break under AutoCommit mode?".IX Subsection "Why do nested statement handles break under AutoCommit mode?"The same explanation as above applies. The workaround is alsomuch alike:.PP.Vb 5\& {\&     $dbh\->{AutoCommit} = 0;\&     $sth1 = $dbh\->prepare("SELECT * FROM $table");\&     $sth2 = $dbh\->prepare("SELECT * FROM $table WHERE id = ?");\&     $sth1\->execute;\&\&     while ($row = $sth1\->fetchrow_arrayref) {\&        $sth2\->execute($row\->[0]);\&        $res = $sth2\->fetchall_arrayref;\&     }\&     $dbh\->commit;\& }.Ve.PPYou may also use \f(CW$dbh\fR\->{ib_softcommit} introduced in version 0.30, please checkt/70nested\-sth.t for an example on how to use it..Sh "Why do placeholders fail to bind, generating unknown datatype error message?".IX Subsection "Why do placeholders fail to bind, generating unknown datatype error message?"You can't bind a field name. The following example will fail:.PP.Vb 2\& $sth = $dbh\->prepare("SELECT (?) FROM $table");\& $sth\->execute(\*(Aquser_id\*(Aq);.Ve.PPThere are cases where placeholders can't be used in conjunction with \s-1COLLATE\s0clause, such as this:.PP.Vb 1\& SELECT * FROM $table WHERE UPPER(author) LIKE UPPER(? COLLATE FR_CA);.Ve.PPThis deals with the InterBase's \s-1SQL\s0 parser, not with \f(CW\*(C`DBD::InterBase\*(C'\fR. Thedriver just passes \s-1SQL\s0 statements through the engine..Sh "How to do automatic increment for a specific field?".IX Subsection "How to do automatic increment for a specific field?"Create a generator and a trigger to associate it with the field. Thefollowing example creates a generator named \s-1PROD_ID_GEN\s0, and a trigger fortable \s-1ORDERS\s0 which uses the generator to perform auto increment on field\&\s-1PRODUCE_ID\s0 with increment size of 1..PP.Vb 7\& $dbh\->do("CREATE GENERATOR PROD_ID_GEN");\& $dbh\->do(\& "CREATE TRIGGER INC_PROD_ID FOR ORDERS\& BEFORE INSERT POSITION 0\& AS BEGIN\&   NEW.PRODUCE_ID = GEN_ID(PROD_ID_GEN, 1);\& END");.Ve.Sh "How can I perform \s-1LIMIT\s0 clause as I usually do in MySQL?".IX Subsection "How can I perform LIMIT clause as I usually do in MySQL?"\&\f(CW\*(C`LIMIT\*(C'\fR clause let users to fetch only a portion rather than the whole records as the result of a query. This is particularly efficient and useful for paging feature on web pages, where users can navigate back and forth between pages..PPUsing InterBase (Firebird is explained later), this can be emulated by writing astored procedure. For example, to display a portion of table_forum, first create the following procedure:.PP.Vb 10\& CREATE PROCEDURE PAGING_FORUM (start INTEGER, num INTEGER)\& RETURNS (id INTEGER, title VARCHAR(255), ctime DATE, author VARCHAR(255))\& AS \& DECLARE VARIABLE counter INTEGER;\& BEGIN\&   counter = 0;\&   FOR SELECT id, title, ctime, author FROM table_forum ORDER BY ctime\&      INTO :id, :title, :ctime, :author\&   DO\&   BEGIN\&      IF (counter = :start + :num) THEN EXIT;\&      ELSE\&         IF (counter >= :start) THEN SUSPEND;\&      counter = counter + 1;          \&   END\& END !!\& SET TERM ; !!.Ve.PPAnd within your application:.PP.Vb 2\& # fetch record 1 \- 5:\& $res = $dbh\->selectall_arrayref("SELECT * FROM paging_forum(0,5)");\&\& # fetch record 6 \- 10: \& $res = $dbh\->selectall_arrayref("SELECT * FROM paging_forum(5,5)");.Ve.PPBut never expect this to work:.PP.Vb 4\& $sth = $dbh\->prepare(<<\*(AqSQL\*(Aq);\& EXECUTE PROCEDURE paging_forum(5,5) \& RETURNING_VALUES :id, :title, :ctime, :author\& SQL.Ve.PPWith Firebird 1 RCx and later, you can use \f(CW\*(C`SELECT FIRST\*(C'\fR:.PP.Vb 1\& SELECT FIRST 10 SKIP 30 * FROM table_forum;.Ve.PP\&\f(CW\*(C`FIRST x\*(C'\fR and \f(CW\*(C`SKIP x\*(C'\fR are both optional. \f(CW\*(C`FIRST\*(C'\fR limits the number ofrows to return, \f(CW\*(C`SKIP\*(C'\fR ignores (skips) the first x rows in resultset..Sh "How can I use the date/time formatting attributes?".IX Subsection "How can I use the date/time formatting attributes?"Those attributes take the same format as the C function \fIstrftime()\fR's.Examples:.PP.Vb 5\& $attr = {\&    ib_timestampformat => \*(Aq%m\-%d\-%Y %H:%M\*(Aq,\&    ib_dateformat => \*(Aq%m\-%d\-%Y\*(Aq,\&    ib_timeformat => \*(Aq%H:%M\*(Aq,\& };.Ve.PPThen, pass it to \fIprepare()\fR method..PP.Vb 2\& $sth = $dbh\->prepare($stmt, $attr);\& # followed by execute() and fetch(), or:\&\& $res = $dbh\->selectall_arrayref($stmt, $attr);.Ve.Sh "Can I set the date/time formatting attributes between prepare and fetch?".IX Subsection "Can I set the date/time formatting attributes between prepare and fetch?"No. \f(CW\*(C`ib_dateformat\*(C'\fR, \f(CW\*(C`ib_timeformat\*(C'\fR, and \f(CW\*(C`ib_timestampformat\*(C'\fR can onlybe set during \f(CW$sth\fR\->prepare. If this is a problem to you, let me know, andprobably I'll add this capability for the next release..Sh "Can I change ib_dialect after \s-1DBI\-\s0>connect ?".IX Subsection "Can I change ib_dialect after DBI->connect ?"No. If this is a problem to you, let me know, and probably I'll add this capability for the next release..Sh "Why do \fIexecute()\fP, \fIdo()\fP method and \fIrows()\fP method always return \-1 upon a successful operation?".IX Subsection "Why do execute(), do() method and rows() method always return -1 upon a successful operation?"Incorrect question. \f(CW$sth\fR\->rows returns the number of fetched rows after asuccessful \s-1SELECT\s0. Starting from version 0.43, \fIexecute()\fR method returns thenumber of affected rows. But it's true that \fIdo()\fR method returns \-1, thiswill change in future release..SH "OBSOLETE FEATURES".IX Header "OBSOLETE FEATURES".IP "Private Method" 4.IX Item "Private Method"\&\f(CW\*(C`set_tx_param()\*(C'\fR is obsoleted by \f(CW\*(C`ib_set_tx_param()\*(C'\fR..SH "TESTED PLATFORMS".IX Header "TESTED PLATFORMS".Sh "Clients".IX Subsection "Clients".IP "Linux" 4.IX Item "Linux".PD 0.IP "FreeBSD" 4.IX Item "FreeBSD".IP "\s-1SPARC\s0 Solaris" 4.IX Item "SPARC Solaris".IP "Win32" 4.IX Item "Win32".PD.Sh "Servers".IX Subsection "Servers".IP "InterBase 6.0/6.01 \s-1SS\s0 and Classic for Linux" 4.IX Item "InterBase 6.0/6.01 SS and Classic for Linux".PD 0.IP "InterBase 6.0/6.01 for Windows, FreeBSD, \s-1SPARC\s0 Solaris" 4.IX Item "InterBase 6.0/6.01 for Windows, FreeBSD, SPARC Solaris".IP "FirebirdSS 1.0 Final for Windows, Linux, \s-1SPARC\s0 Solaris" 4.IX Item "FirebirdSS 1.0 Final for Windows, Linux, SPARC Solaris".IP "FirebirdSS 1.5.2.4731 for Windows, Linux" 4.IX Item "FirebirdSS 1.5.2.4731 for Windows, Linux".IP "FirebirdSS 2.0 \s-1RC4\s0 for Linux. The \s-1AMD64\s0 (64\-bit) version is also tested. Should also work with Intel \s-1EM64T\s0." 4.IX Item "FirebirdSS 2.0 RC4 for Linux. The AMD64 (64-bit) version is also tested. Should also work with Intel EM64T.".PD.SH "AUTHORS".IX Header "AUTHORS".IP "\(bu" 4\&\s-1DBI\s0 by Tim Bunce <Tim.Bunce@pobox.com>.IP "\(bu" 4DBD::InterBase by Edwin Pratomo <edpratomo@cpan.org> and Daniel Ritz <daniel.ritz@gmx.ch>..SpThis module is originally based on the work of Bill Karwin's IBPerl..SH "BUGS/LIMITATIONS".IX Header "BUGS/LIMITATIONS"Please report bugs and feature suggestions using http://rt.cpan.org/Public/Dist/Display.html?Name=DBD\-InterBase..PPThis module doesn't work with MSWin32 ActivePerl iThreads, and its emulatedfork. Tested with MSWin32 ActivePerl build 809 (Perl 5.8.3). The wholeprocess will block in unpredictable manner..PPUnder Linux, this module has been tested with several different iThreadsenabled Perl releases: perl\-5.8.0\-88 from RedHat 9, perl\-5.8.5\-9 from FedoraCore 3, perl\-5.8.6\-15 from Fedora Core 4, and Perl 5.8.[78]..PPNo problem occurred so far.. until you try to share a \s-1DBI\s0 handle ;\-).PPBut if you plan to use thread, you'd better use the latest stable version ofPerl, 5.8.8 has fairly stable iThreads..PPLimitations:.IP "\(bu" 4Arrays are not (yet) supported.IP "\(bu" 4Read/Write \s-1BLOB\s0 fields block by block not (yet) supported. Themaximum size of a \s-1BLOB\s0 read/write is hardcoded to about 1 \s-1MB\s0..IP "\(bu" 4service manager \s-1API\s0 is not supported..SH "SEE ALSO".IX Header "SEE ALSO"\&\s-1\fIDBI\s0\fR\|(3)..SH "COPYRIGHT".IX Header "COPYRIGHT"The DBD::InterBase module is Copyright (c) 1999\-2008 Edwin Pratomo.Portions Copyright (c) 2001\-2005 Daniel Ritz..PPThe DBD::InterBase module is free software. You may distribute under the terms of either the \s-1GNU\s0 General PublicLicense or the Artistic License, as specified in the Perl \s-1README\s0 file,with the exception that it cannot be placed on a CD-ROM or similar mediafor commercial distribution without the prior approval of the author..SH "ACKNOWLEDGEMENTS".IX Header "ACKNOWLEDGEMENTS"An attempt to enumerate all who have contributed patches (may misses some):Michael Moehle, Igor Klingen, Sergey Skvortsov, Ilya Verlinsky, PavelZheltouhov, Peter Wilkinson, Mark D. Anderson, Michael Samanov, MichaelArnett, Flemming Frandsen, Mike Shoyher, Christiaan Lademann.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -