--- PApp-SQL/SQL.pm 2001/04/22 14:38:27 1.15 +++ PApp-SQL/SQL.pm 2002/02/27 04:32:39 1.21 @@ -1,6 +1,6 @@ =head1 NAME -PApp::SQL - absolutely easy yet fast and powerful sql access +PApp::SQL - absolutely easy yet fast and powerful sql access. =head1 SYNOPSIS @@ -15,7 +15,7 @@ my $a = sql_fetch "select a from ..."; sql_fetch \my($a, $b), "select a,b ..."; - sql_exists "name from table where name like 'a%'" + sql_exists "table where name like 'a%'" or die "a* required but not existent"; my $db = new PApp::SQL::Database "", "DBI:mysql:test", "user", "pass"; @@ -46,10 +46,10 @@ BEGIN { use base qw(Exporter DynaLoader); - $VERSION = 0.123; + $VERSION = 0.13; @EXPORT = qw( - sql_exec sql_fetch sql_fetchall sql_exists sql_insertid $sql_exec - sql_ufetch sql_ufetchall sql_uexists + sql_exec sql_fetch sql_fetchall sql_exists sql_insertid $sql_exec + sql_uexec sql_ufetch sql_ufetchall sql_uexists ); @EXPORT_OK = qw( connect_cached @@ -125,6 +125,9 @@ # try your luck opening the papp database without access info $dbh = connect_cached __FILE__, "DBI:mysql:papp"; +Mysql-specific behaviour: The default setting of +C is TRUE, you can overwrite this, though. + =cut sub connect_cached { @@ -132,9 +135,14 @@ # the following line is duplicated in PApp::SQL::Database::new $id = "$id\0$dsn\0$user\0$pass"; unless ($dbcache{$id} && $dbcache{$id}->ping) { - #warn "connecting to ($dsn|$user|$pass|$flags)\n";#d# # first, nuke our statement cache (sooory ;) cachesize cachesize 0; + + # then make mysql behave more standardly by default + $dsn =~ /^[Dd][Bb][Ii]:mysql:/ + and $dsn !~ /;mysql_client_found_rows/ + and $dsn .= ";mysql_client_found_rows=1"; + # then connect anew $dbcache{$id} = eval { DBI->connect($dsn, $user, $pass, $flags) } @@ -214,7 +222,9 @@ ... 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. +utf8 and forces all result values to utf8 (this does I include result +parameters, only return values. Using bind variables in cinjunction with +sql_u* functions results in undefined behaviour). =item sql_fetchall @@ -241,9 +251,10 @@ } C is similar to C but upgrades all input -values to utf8 and forces all result values to utf8. +values to utf8 and forces all result values to utf8 (see the caveats in +the description of C, though). -=item sql_exists " where ...", args... +=item sql_exists " where ...", args... =item sql_uexists