... | ... |
@@ -142,7 +142,7 @@ sub dbh_option { |
142 | 142 |
return $dbh->{$_[0]} |
143 | 143 |
} |
144 | 144 |
|
145 |
- |
|
145 |
+# Create SQL from SQL template |
|
146 | 146 |
sub create_sql { |
147 | 147 |
my $self = shift; |
148 | 148 |
|
... | ... |
@@ -151,6 +151,7 @@ sub create_sql { |
151 | 151 |
return ($sql, @bind); |
152 | 152 |
} |
153 | 153 |
|
154 |
+# Prepare and execute SQL |
|
154 | 155 |
sub query { |
155 | 156 |
my ($self, $template, $values, $filter) = @_; |
156 | 157 |
|
... | ... |
@@ -177,9 +178,10 @@ sub query { |
177 | 178 |
} |
178 | 179 |
} |
179 | 180 |
|
181 |
+ # Execute |
|
180 | 182 |
my $ret_val = $sth->execute(@bind); |
181 | 183 |
|
182 |
- # Select |
|
184 |
+ # Return resultset if select statement is executed |
|
183 | 185 |
if ($sth->{NUM_OF_FIELDS}) { |
184 | 186 |
my $result_class = $self->result_class; |
185 | 187 |
my $result = $result_class->new({ |
... | ... |
@@ -191,19 +193,25 @@ sub query { |
191 | 193 |
return $ret_val; |
192 | 194 |
} |
193 | 195 |
|
194 |
- |
|
196 |
+# Prepare and execute raw SQL |
|
195 | 197 |
sub query_raw_sql { |
196 |
- my ($self, $sql, @bind) = @_; |
|
198 |
+ my ($self, $sql, @bind_values) = @_; |
|
197 | 199 |
|
200 |
+ # Connect |
|
198 | 201 |
$self->connect unless $self->connected; |
202 |
+ |
|
203 |
+ # Add semicolon if not exist; |
|
199 | 204 |
$sql .= ';' unless $sql =~ /;$/; |
205 |
+ |
|
206 |
+ # Prepare |
|
200 | 207 |
my $sth = $self->dbh->prepare($sql); |
201 |
- $sth->execute(@bind); |
|
208 |
+ |
|
209 |
+ # Execute |
|
210 |
+ $sth->execute(@bind_values); |
|
211 |
+ |
|
202 | 212 |
return $sth; |
203 | 213 |
} |
204 | 214 |
|
205 |
- |
|
206 |
- |
|
207 | 215 |
Object::Simple->build_class; |
208 | 216 |
|
209 | 217 |
package DBI::Custom::Result; |
... | ... |
@@ -216,7 +224,6 @@ sub fetchrow_arrayref { |
216 | 224 |
my $self = shift; |
217 | 225 |
my $sth = $self->{sth}; |
218 | 226 |
|
219 |
- $DB::single = 1; |
|
220 | 227 |
my $array = $sth->fetchrow_arrayref; |
221 | 228 |
|
222 | 229 |
return $array unless $array; |