]>
jfr.im git - irc/SurrealServices/srsv.git/blob - branches/mus-0.4.x-devel/SrSv/DB/StubGen.pm
1 # This file is part of Invid
3 # Invid is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License version 2.1 as published by the Free Software Foundation.
7 # This library is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 # Lesser General Public License for more details.
12 # You should have received a copy of the GNU Lesser General Public
13 # License along with this library; if not, write to the Free Software
14 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 # Copyright Adam Schrotenboer <adam@tabris.net> 2007, 2008
19 # This code is based in large part on the MySQL::Stub from SrSv, as well as
20 # the DB::Sub from M2000's CMS.
24 Invid::DB::Stub - Create functions for SQL queries
28 package SrSv
::DB
::StubGen
;
33 require SrSv
::DB
::StubGen
::Stub
;
38 shift @_; # Remove package name from arg list.
39 my %stubhash = @_; # Basically we coerce the list back into a hash.
40 my $generator = $stubhash{generator
};
41 my $dbh = $stubhash{dbh
};
43 import SrSv
::DB
::StubGen
::Stub
($package, $dbh, @_);
46 # Export subroutine into caller's namespace.
49 *{"${package}::${generator}"} = $sub;
57 use SrSv::DB::StubGen {
59 generator => 'main_sql_stub',
64 The point of this is that although SrSv::DB::Stub is bloody useful, it
65 only lets you use one $dbh per program. What if you have more than one
70 See SrSv::DB::Stub for how you use the generator function.
74 use SrSv::DB::Stub ( ... )