DBIx-Custom
view release on metacpan or search on metacpan
}
}
}
# bind_type option
{
{
my $dbi = DBIx::Custom->connect(
dsn => 'dbi:SQLite:dbname=:memory:',
option => {
$DBD::SQLite::VERSION > 1.26 ? (sqlite_unicode => 1) : (unicode => 1)
}
);
my $binary = pack("I3", 1, 2, 3);
eval { $dbi->execute('drop table table1') };
$dbi->execute('create table table1(key1, key2)');
$dbi->insert({key1 => $binary, key2 => 'ã'}, table => 'table1', bind_type => [key1 => DBI::SQL_BLOB]);
{
my $result = $dbi->select(table => 'table1');
my $row = $result->one;
is_deeply($row, {key1 => $binary, key2 => 'ã'}, "basic");
{
my $result = $dbi->execute('select length(key1) as key1_length from table1');
my $row = $result->one;
is($row->{key1_length}, length $binary);
}
}
{
my $dbi = DBIx::Custom->connect(
dsn => 'dbi:SQLite:dbname=:memory:',
option => {
$DBD::SQLite::VERSION > 1.26 ? (sqlite_unicode => 1) : (unicode => 1)
}
);
my $binary = pack("I3", 1, 2, 3);
eval { $dbi->execute('drop table table1') };
$dbi->execute('create table table1(key1, key2)');
$dbi->insert({key1 => $binary, key2 => 'ã'}, table => 'table1', bind_type => {key1 => DBI::SQL_BLOB});
{
my $result = $dbi->select(table => 'table1');
my $row = $result->one;
is_deeply($row, {key1 => $binary, key2 => 'ã'}, "basic");
( run in 0.507 second using v1.01-cache-2.11-cpan-88abd93f124 )