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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:05:28+00:00 2026-05-23T14:05:28+00:00

I would like to return all the results from my prepared query (mysqli) as

  • 0

I would like to return all the results from my prepared query (mysqli) as objects in an array but i cant find a fetchall method or something similar. How do i go about this?

public function getImageResults ($search_term)
{
        if (empty($search_term))
            return false;

        $image_query = $this->db_connection->stmt_init();

        $image_query_sql =
        "
            SELECT 
                Images.url as url
            FROM 
                Images, ImageSearch, ImageSearchResults 
            WHERE 
                ImageSearch.search_string = ? AND
                ImageSearchResults.search_id = ImageSearch.id AND
                ImageSearchResults.image_id = Images.id AND

                Images.deleted = 0 AND
                ImageSearch.deleted = 0 AND
                ImageSearchResults.deleted = 0
        ";

        if ($image_query->prepare($image_query_sql))
        {
            $image_query->bind_param('s', $search_term);

            $image_query->execute();
            $image_query->store_result();
            $image_query->bind_result($url);

            return //need to return the entire result set here... any ideas?
        }

        return false;
}

I found this code on the net which kinda works but i get this error when i use it

Notice: Use of undefined constant
mysqli_stmt_bind_result – assumed
‘mysqli_stmt_bind_result’

private function getresult ($stmt)
    {
        $result = array();

        $metadata = $stmt->result_metadata();
        $fields = $metadata->fetch_fields();

        for (;;)
        {
            $pointers = array();
            $row = new stdClass();

            $pointers[] = $stmt;
            foreach ($fields as $field)
            {
                $fieldname = $field->name;
                $pointers[] = &$row->$fieldname;
            }

            call_user_func_array(mysqli_stmt_bind_result, $pointers);

            if (!$stmt->fetch())
                break;

            $result[] = $row;
        }

        $metadata->free();

        return $result;
    }
  • 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-05-23T14:05:28+00:00Added an answer on May 23, 2026 at 2:05 pm

    The mysqli_stmt_bind_result on this line:

    call_user_func_array(mysqli_stmt_bind_result, $pointers);
    

    should be quoted:

    call_user_func_array('mysqli_stmt_bind_result', $pointers);
    

    You could also use PDO, an untested example but it should work:

    public function getImageResults ($search_term)
    {
        $sql =
        "
            SELECT 
                Images.url as url
            FROM 
                Images, ImageSearch, ImageSearchResults 
            WHERE 
                ImageSearch.search_string = ? AND
                ImageSearchResults.search_id = ImageSearch.id AND
                ImageSearchResults.image_id = Images.id AND
    
                Images.deleted = 0 AND
                ImageSearch.deleted = 0 AND
                ImageSearchResults.deleted = 0
        ";
        $pdo = new PDO('mysql:dbname=testdb;host=127.0.0.1', 'username', 'password');
    
        $sth = $pdo->prepare($sql);
        $sth->execute(array($search_term));
    
        $result = $sth->fetchAll(PDO::FETCH_CLASS, "ArrayObject");
    
        //var_dump($result);//debug
    
        return $result;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to find all comment blocks(/*...*/) but the function g_regex_match_full always returns
I have a query that uses a UNION ALL to return results from two
Given the following XML, I would like to return all eventtitles where the eventtype
I would like to return an array of string in my web services I've
I'm using the below query to return results from a table using Full-Text-Search. In
i use JSon to return allot of results when building a website, but find
I would like to return the id of a newly created object for my
I have a MySQL table and would like to return the rows based on
I have a method where I would like to return an object instance of
I have a function that I would like to return 0 if a certain

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.