GX/SQL/Builder/MySQL.pm untested

filter: Statementstmt 0.0% 0 / 20 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 42 CC 4 SCAR 25.1
CC
4
Cov
0%
_build_limit_clause
20.0
_initialize_quote_char
2.0
BEGIN
2.0
CRAP 12.3
1 # ----------------------------------------------------------------------------------------------------------------------
2 # GX Framework (c) 2009-2011 Jörg A. Uzarek <uzarek@runlevelnull.de>
3 # File: GX/SQL/Builder/MySQL.pm
4 # ----------------------------------------------------------------------------------------------------------------------
5  
6 package GX::SQL::Builder::MySQL;
7  
8 use GX::Exception;
9  
10  
11 # ----------------------------------------------------------------------------------------------------------------------
12 # Class setup
13 # ----------------------------------------------------------------------------------------------------------------------
14  
15 use GX::Class ( extends => 'GX::SQL::Builder' );
16  
17 build;
18  
19  
20 # ----------------------------------------------------------------------------------------------------------------------
21 # Private methods
22 # ----------------------------------------------------------------------------------------------------------------------
23  
24 sub _build_limit_clause {
25  
26 my ( $self, $limit, $offset, $sql, @bind ) = @_;
27  
28 if ( defined $limit ) {
29 $limit =~ /^\d+$/ or throw "Invalid argument (\"limit\" must be a number)";
30 }
31 else {
32 return;
33 }
34  
35 if ( defined $offset ) {
36 $offset =~ /^\d+$/ or throw "Invalid argument (\"offset\" must be a number)";
37 }
38 else {
39 $offset = 0;
40 }
41  
42 # MySQL limit syntax:
43 # "ORDER BY $order LIMIT $limit"
44 # "ORDER BY $order LIMIT $offset, $limit"
45  
46 if ( $offset ) {
47 $$sql .= ' LIMIT ' . $offset . ', ' . $limit;
48 }
49 else {
50 $$sql .= ' LIMIT ' . $limit;
51 }
52  
53 return;
54  
55 }
56  
57  
58 # ----------------------------------------------------------------------------------------------------------------------
59 # Attribute initializers
60 # ----------------------------------------------------------------------------------------------------------------------
61  
62 sub _initialize_quote_char {
63  
64 return '`';
65  
66 }
67  
68  
69 1;
70  
71 __END__