Thank so very much for the above answer.
And I have another question as well. I did use the selectall_array_ref to execute this query. and when I try to print in the sub nextWords. it does work and prints out all the result that i have expected.
- sub nextWords {
-
my ($id, $offset) = @_;
-
my @array = ();
-
my $statement = $db->selectall_arrayref("select word from words
-
left outer join language
-
on words.languageId = language.languageId
-
where words.languageId = $id
-
order by word asc
-
limit 10 offset $offset;");
-
-
my @main= ();
-
foreach my $i (@$statement)
-
{
-
push(@main, @{$i}[0]);
-
}
-
@array[$id] = [@main];
-
-
return @array;
-
}
-
-
my $lang_size = languages();
-
for my $id(1 .. $lang_size ){
-
-
print "=======ID = " . $id . "=======\n";
-
my $self->{CURRENTOFFSET} = 0;
-
NAME: while (1 > 0){
-
my @newwordsList = nextWords($id,$self->{CURRENTOFFSET});
-
-
$self->{CURRENTOFFSET}+= 10;
-
-
foreach my $k (@{@newwordsList[$id]}) {
-
print $k . "\n";
-
}
-
print "\n";
-
if (!@{@newwordsList[$id]}[0]) {
-
last NAME;
-
}
-
}
-
}
However, when i try to print out by create and other file.pl to compile it. it doesnt work, it give an error "DBD::SQLite::db selectall_arrayref failed: unrecognized token: "0x1db16c".
- $object = DataLayer->new();
-
print $object->nextWords();
-
-
for my $id( 1 .. 3)
-
{
-
my $offset= 0;
-
NAME: while (1>0)
-
{
-
my @wordList = $object->nextWords($id, $offset);
-
$offset+=10;
-
foreach my $k (@{@wordList[$id]}) {
-
print $k . "\n";
-
}
-
if (!@{@wordList[$id]}[0]) {
-
last NAME;
-
}
-
}
-
}
-
thanks in advance..