#!/usr/bin/perl
use strict; # https://perlmonks.org/?node_id=11123285
use warnings;
use DBI;
my $dbfile = 'db.11123285';
unlink $dbfile;
my $db = DBI->connect_cached(
"DBI:SQLite(RaiseError=>1,PrintError=>0):$dbfile");
eval
{
$db->do('create table note (id integer primary key, ts int, mess tex
+t)');
$db->do('insert into note (ts, mess) values (?, ?)', {}, 1, 'one');
$db->do('insert into note (ts, mess) values (?, ?)', {}, 2, 'two');
};
#system "sqlite3 $dbfile .dump";
my $sth = $db->prepare_cached('select * from note where id = ?');
$sth->bind_param(1, 2);
$sth->execute;
my @data = $sth->fetchrow_array;
use Data::Dump 'dd'; dd \@data;
$sth = $db->prepare_cached('select * from note where id = ?', {}, 1);
+# HERE
$sth->bind_param(1, 1);
$sth->execute;
@data = $sth->fetchrow_array;
use Data::Dump 'dd'; dd \@data;
unlink $dbfile; # cleanup
Outputs:
[2, 2, "two"]
[1, 1, "one"]
Note that the "still Active" message does not prevent correct execution, so something else must be causing your lack of data.
|