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 8800235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:31:57+00:00 2026-06-14T00:31:57+00:00

I am using this statement to fetch the elements in a column in my

  • 0

I am using this statement to fetch the elements in a column in my db

$result = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);

but I get this error when trying to run it.

Call to undefined method mysqli_stmt::fetchAll();

Is there something I need to add to my php file to include that method or something?

UPDATE 1:

class LoginAPI
{
private $db;

function __construct() 
{
    $this->db = new mysqli('xxx', 'xxx', 'xxx', 'xxx');
    $this->db->autocommit(FALSE);
}

function __destruct() 
{
    $this->db->close();
}

function login() 
{
    if(isset($_POST["lang"]))
    {
        $stmt = $this->db->prepare("SELECT code FROM locations");
        $stmt->execute();
        $stmt->bind_result($code);

        //while($stmt->fetch())
        //{
        //  result[] = "code"=>$code;
        //  break;
        //}
        $codeArr = array();
        $result = $stmt->fetch_all();//|PDO::FETCH_GROUP;




        sendResponse(200, json_encode($result));
        return true;
    }
    sendResponse(400, 'Invalid Request');
    return false;
}
}
  • 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-14T00:31:58+00:00Added an answer on June 14, 2026 at 12:31 am

    You’re using mysqli, and you’ve got a statement not a result. If you have a mysqli_result you could be using the method fetch_all().

    However, as this is a mysqli_stmt, you first need to execute and then use fetch_all() on the result set. See below example

     $stmt = $this->db->prepare("SELECT code FROM locations");
     $stmt->execute();
    
    
    //grab a result set
    $resultSet = $stmt->get_result();
    
    //pull all results as an associative array
    $result = $resultSet->fetch_all();
    

    Note: with fetch_all you don’t need to bind the result as your original code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to change table name from lowercase to uppercase but using this statement
I have a problem when trying to execute this update statement (below) using C#
I'm using Python 2.5. I'm trying to use this 'with' statement. from __future__ import
Just a quick question. Is there any performance difference between using PDO::fetchAll() and PDO::fetch()
Using this SP I keep getting an error on the UPDATE statement indicating that
My array would only get a 0 or a 1. I'm using PDO statement
I'm using this statement in SQLServer and it works fine: SELECT TOP 1000 *
Getting red warning message that expected identifier for this statement CALayer = ImageView.layer; Using
I saw this C# using statement in a code example: using StringFormat=System.Drawing.StringFormat; What's that
I have a using statement defined like this in codebehind: using Name = Extremely.Long.And.Unwieldy.Namespace

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.