--- PApp-SQL/SQL.pm 2001/03/11 14:54:21 1.14 +++ PApp-SQL/SQL.pm 2001/04/22 14:38:27 1.15 @@ -29,7 +29,8 @@ commands (using DBI). Despite being easy to use, they are also quite efficient and allow you to write faster programs in less lines of code. It should work with anything from perl-5.004_01 onwards, but I only support -5.005+. +5.005+. UTF8 handling (the C family of functions) will only be +effective with perl version 5.006 and beyond. If the descriptions here seem terse or if you always wanted to know what PApp is then have a look at the PApp module which uses this module @@ -45,9 +46,10 @@ BEGIN { use base qw(Exporter DynaLoader); - $VERSION = 0.122; + $VERSION = 0.123; @EXPORT = qw( sql_exec sql_fetch sql_fetchall sql_exists sql_insertid $sql_exec + sql_ufetch sql_ufetchall sql_uexists ); @EXPORT_OK = qw( connect_cached @@ -145,6 +147,8 @@ =item $sth = sql_exec [dbh,] [bind-vals...,] "sql-statement", [arguments...] +=item $sth = sql_uexec + C is the most important and most-used function in this module. Runs the given sql command with the given parameters and returns the @@ -165,6 +169,9 @@ If any error occurs C will throw an exception. +C is similar to C but upgrades all input arguments to +utf8 before calling the C method. + Examples: # easy one @@ -183,7 +190,9 @@ =item sql_fetch -Execute a sql-statement and fetch the first row of results. Depending on +=item sql_ufetch + +Execute an sql-statement and fetch the first row of results. Depending on the caller context the row will be returned as a list (array context), or just the first columns. In table form: @@ -204,8 +213,13 @@ ... and it's still quite fast unless you fetch large amounts of data. +C is similar to C but upgrades all input values to +utf8 and forces all result values to utf8. + =item sql_fetchall +=item sql_ufetchall + Similarly to C, but all result rows will be fetched (this is of course inefficient for large results!). The context is ignored (only list context makes sense), but the result still depends on the number of @@ -226,14 +240,22 @@ my ($name, $age, $place) = @$_; } +C is similar to C but upgrades all input +values to utf8 and forces all result values to utf8. + =item sql_exists " where ...", args... +=item sql_uexists + Check wether the result of the sql-statement "select xxx from $first_argument" would be empty or not (that is, imagine the string "select * from" were prepended to your statement (it isn't)). Should work with every database but can be quite slow, except on mysql, where this should be quite fast. +C is similar to C but upgrades all parameters to +utf8. + Examples: print "user 7 exists!\n" @@ -316,9 +338,10 @@ =head2 THE DATABASE CLASS -Again (sigh) the problem of persistency. What do you do when you have to serialize on object -that contains (or should contain) a database handle? Short answer: you don't. Long answer: -you can embed the necessary information to recreate the dbh when needed. +Again (sigh) the problem of persistency. What do you do when you have +to serialize on object that contains (or should contain) a database +handle? Short answer: you don't. Long answer: you can embed the necessary +information to recreate the dbh when needed. The C class does that, in a relatively efficient fashion: the overhead is currently a single method call per access (you