Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8348901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:49:41+00:00 2026-06-09T07:49:41+00:00

my code is the following: sub new { my $class = shift; my $self

  • 0

my code is the following:

sub new {
    my $class = shift;
    my $self = bless {}, $class;

    $self->initialize();

    return $self;
}

sub initialize
{
    my $self = shift;

    $self->connect();

    $self->{'dbh'}
        ->do("CREATE TABLE IF NOT EXISTS 'settings' (Id INTEGER PRIMARY KEY, Option TEXT, Value TEXT)");
}

sub connect
{
    my $self = shift;

    $self->{'dbh'} = DBI->connect($self->DSN, "", "", {
        RaiseError => 1,
        AutoCommit => 1
    });

    die "Can't connect" unless($self->{'dbh'});
}

sub no_options
{
    my$self = shift;

    $self->{'dbh'}->prepare("SELECT COUNT(*) as Total FROM settings");
    # Here is the problem i get the error here:
    # Can't locate object method "execute" via package "DBI::db"
    $self->{'dbh'}->execute();
    my %row = $self->{'dbh'}->fetchhash_array;

    return $row{'Total'};
}

in other place i call my package

my $test = Lib::PackageName->new;

print $test->no_options;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T07:49:42+00:00Added an answer on June 9, 2026 at 7:49 am

    The prepare method returns a statement object. It is this object that has the execute method.

    my $statement = $self->{'dbh'}->prepare("SELECT COUNT(*) as Total FROM settings");
    $statement->execute();
    

    There is no method named fetchhash_array in DBI. The available fetch methods for the statement object are:

    • fetchrow_arrayref
    • fetchrow_array
    • fetchrow_hashref
    • fetchall_arrayref
    • fetchall_hashref
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code in my class : sub new { my $class
I have the following code: Imports System.IO Public Class Blah Public Sub New() InitializeComponent()
Using the following code: Private Sub MakeMeSomeXmlBeforeRyanGetsAngry() Dim db As New MyDBDataContext Dim customer
I have the following code: Imports MySql.Data.MySqlClient Imports MySql.Data.Types Public Class FormMain Private Sub
I have the following code to create my window, my view and my sub
please look at the following code first. #! /usr/bin/perl package foo; sub new {
Using the following code here Sub FooSub Dim db As New FooDataContext Dim u
I have the following code: Public Class TestClass Public Sub Main() If theGlobal IsNot
I have the following code: class SuperClass { public static String getName() { return
i have the following code: Private Sub TxtPStof_KeyPress(ByVal sender As System.Object, ByVal e As

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.