UNIX や web やプログラムの技術的なことを中心に。
|
|
use DBI;
my $dbh = DBI->connect(
'DBI:mysql:dbname', 'user', 'password',
{AutoCommit => 0, RaiseError => 1, PrintError => 0}
) || die;
my $sth = $dbh->prepare("select * from not_exist_table");
$sth->execute;
DBD::mysql::st execute failed: Table 'dbname.not_exist_table' doesn't exist at a line 5.
Can't call method "execute" on an undefined value at b line 6.となってしまった。一応プログラムは異常終了しているのだが、これはテーブルが
my $sth = $dbh->prepare("select * from not_exist_table") || die "$DBI::errstr";Prepared statement support (server side prepare)
As of 3.0002_1, server side prepare statements are on by default
(if your server is >= 4.1.3)
To use driver emulated prepared statements, all you need to do
is set the variable mysql_emulated_prepare in the connect:
$dbh = DBI->connect( "DBI:mysql:database=test;host=localhost;mysql_emulated_prepare=1",
"", "", { RaiseError => 1, AutoCommit => 1 } );
* Note: delimiter for this param is ';'
To make sure that the 'make test' step tests whether server prepare works,
you just need to export the env variable MYSQL_SERVER_PREPARE:
export MYSQL_EMULATED_PREPARE=1
my $dbh = DBI->connect(
'DBI:mysql:dbname;mysql_emulated_prepare=1', 'user', 'password',
{AutoCommit => 0, RaiseError => 1, PrintError => 0}
) || die;
コメントの投稿