ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/PApp-SQL/SQL.pm
(Generate patch)

Comparing PApp-SQL/SQL.pm (file contents):
Revision 1.30 by stefan, Wed Jan 28 19:50:38 2004 UTC vs.
Revision 1.31 by root, Wed Jan 28 19:58:19 2004 UTC

186package-global (and exported) variable C<$sql_exec>. 186package-global (and exported) variable C<$sql_exec>.
187 187
188If any error occurs C<sql_exec> will throw an exception. 188If any error occurs C<sql_exec> will throw an exception.
189 189
190C<sql_uexec> is similar to C<sql_exec> but upgrades all input arguments to 190C<sql_uexec> is similar to C<sql_exec> but upgrades all input arguments to
191utf8 before calling the C<execute> method. 191UTF-8 before calling the C<execute> method.
192 192
193Examples: 193Examples:
194 194
195 # easy one 195 # easy one
196 my $st = sql_exec "select name, id from table where id = ?", $id; 196 my $st = sql_exec "select name, id from table where id = ?", $id;
230 my($name, $amount) = sql_fetch "select ...", args... 230 my($name, $amount) = sql_fetch "select ...", args...
231 231
232... and it's still quite fast unless you fetch large amounts of data. 232... and it's still quite fast unless you fetch large amounts of data.
233 233
234C<sql_ufetch> is similar to C<sql_fetch> but upgrades all input values to 234C<sql_ufetch> is similar to C<sql_fetch> but upgrades all input values to
235utf8 and forces all result values to utf8 (this does I<not> include result 235UTF-8 and forces all result values to UTF-8 (this does I<not> include result
236parameters, only return values. Using bind variables in cinjunction with 236parameters, only return values. Using bind variables in conjunction with
237sql_u* functions results in undefined behaviour - we use utf8_on on 237sql_u* functions might result in undefined behaviour - we use UTF-8 on
238bind-variables and it seems to work on DBD::mysql which just means 238bind-variables at execution time and it seems to work on DBD::mysql as it
239that that DBD-driver is broken). 239ignores the UTF-8 bit completely. Which just means that that DBD-driver is
240broken).
240 241
241=item sql_fetchall <see sql_exec> 242=item sql_fetchall <see sql_exec>
242 243
243=item sql_ufetchall <see sql_uexec> 244=item sql_ufetchall <see sql_uexec>
244 245
261 for (sql_fetchall "select name, age, place from user") { 262 for (sql_fetchall "select name, age, place from user") {
262 my ($name, $age, $place) = @$_; 263 my ($name, $age, $place) = @$_;
263 } 264 }
264 265
265C<sql_ufetchall> is similar to C<sql_fetchall> but upgrades all input 266C<sql_ufetchall> is similar to C<sql_fetchall> but upgrades all input
266values to utf8 and forces all result values to utf8 (see the caveats in 267values to UTF-8 and forces all result values to UTF-8 (see the caveats in
267the description of C<sql_ufetch>, though). 268the description of C<sql_ufetch>, though).
268 269
269=item sql_exists "<table_references> where <where_condition>...", args... 270=item sql_exists "<table_references> where <where_condition>...", args...
270 271
271=item sql_uexists <see sql_exists> 272=item sql_uexists <see sql_exists>
275"select * from" were prepended to your statement (it isn't)). Should work 276"select * from" were prepended to your statement (it isn't)). Should work
276with every database but can be quite slow, except on mysql, where this 277with every database but can be quite slow, except on mysql, where this
277should be quite fast. 278should be quite fast.
278 279
279C<sql_uexists> is similar to C<sql_exists> but upgrades all parameters to 280C<sql_uexists> is similar to C<sql_exists> but upgrades all parameters to
280utf8. 281UTF-8.
281 282
282Examples: 283Examples:
283 284
284 print "user 7 exists!\n" 285 print "user 7 exists!\n"
285 if sql_exists "user where id = ?", 7; 286 if sql_exists "user where id = ?", 7;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines