MQdb::DBStream3pm
Description of object
Usage
A simplified object to manage a collection of information related to streaming data from a database. at least with MYSQL, the perl driver does odd caching so to stream one needs to create a new database connection in order to stream
Overview
Contact
Jessica Severin <[email protected]>
Appendix
The rest of the documentation details each of the object methods. Internal methods are labeled.
set_stream_useresult_behaviour
Description : sets a global behaviour for all DBStreams.setting use_result to "on" will leave the results on the database andwill keep the database connection open durring streaming.Both methods have similar speed performance, but keeping the resultson the database server means the client uses essentially no memory.The risk of turning this on is that the the database connection remains openand there is risk of it timing out if processing takes a long time to stream all data.When turned off, the entire result set is transfered in bulk to the driver (DBD::mysql)and streaming happens from the underlying driver code and the perl code layer.Default is "off" since this is safer but one risks needing lots of memory on the client.Parameter[1] : 1 or "y" or "on" turns the use_result on and keeps the database connection openReturntype : noneExceptions : noneExample : MQdb::DBStream->set_stream_useresult_behaviour(1);
next_in_stream
Description: gets the next object in the stream. If the stream is empty it return undef.Returntype : instance of the defined DBStream::stream_class, or undefExceptions : noneExample :my $stream = WorldKit::Person->stream_all_by_country_region($db, "USA", "wisconsin");while(my $person = $stream->next_in_stream) {#do something}
as_array
Description: instantiates all remaining instances in the stream and returns them as an arrayReturntype : reference to array of instances of the defined class of this streamExceptions : noneExample :my $stream = WorldKit::Person->stream_all_by_country_region($db, "USA", "wisconsin");my $all_people = $stream->as_array; #because I have a large memory machine and need them all in memoryforeach my $person (@$all_people) {#do something}
stream_database
Description: this is an internal system method.Needs to have two database connections open, one for the activestream handle, and one for lazy-loading additional data on the returnedobjects. This is used to set the database which is the one streaming objectsArg (1) : $database (MQdb::Database) for settingReturntype : MQdb::DatabaseExceptions : noneCallers : MQdb::MappedQuery
stream_class
Description: this is an internal system method.Set/get the class used for creation of objects on this stream.The class must be a subclass of MQdb::MappedQueryArg (1) : $class (must be subclass of MQdb::MappedQuery) for settingReturntype : a class which is a subclass of MQdb::MappedQueryExceptions : noneCallers : MQdb::MappedQuery
prepare
Description: this is an internal system method. It is used to set the SQL query usedto stream objects out of a database. Must be have stream_class() setto a subclass of MappedQuery which implements the mapRow() method.Returntype : $selfExceptions : noneCallers : MQdb::MappedQuery
Releases
8 releases since Debian 6.0 (Squeeze); the text changed 2 times.