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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:42:55+00:00 2026-05-22T00:42:55+00:00

I spent 2 hours searching through the other few posts at Stack Overflow concerning

  • 0

I spent 2 hours searching through the other few posts at Stack Overflow concerning this issue and they seemed more complicated than what I needed. I attempted doing the __toString function but I don’t think I did it correctly.

I am trying to take the sql statement for $personid and convert it to a string so I can use it in the other sql methods.

$personid = $this->db->query('SELECT person_id FROM person');

$fullname = $this->db->query("SELECT person_fname, person_lname FROM person
                          WHERE person_id = '".$personid."';");

$sport = $this->db->query("SELECT sport_name FROM person_sport_rel A1
                        INNER JOIN sport A2 ON A1.sport_id = A2.sport_id
                        WHERE person_Id = '".$personid."';");

Just as the other posts had the problem.. the error I receive is

Object of class CI_DB_mysql_result could not be converted to string

I tried adding the constructor and the __toString in the CI_DB_mysql_result class that was recommended on the PHP site but to no avail

  • 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-22T00:42:55+00:00Added an answer on May 22, 2026 at 12:42 am

    You are probably returning a bunch of id’s when you’re running this query:

    $personidsQuery = $this->db->query('SELECT person_id FROM person');
    

    so when you want to re-use it in new queries this is probably more interesting:

    $sql = "SELECT person_fname, person_lname FROM person WHERE person_id = ?";
    foreach ($personidsQuery->result() as $row)
    {
        $namesQuery = $this->db->query($sql, array($row->person_id));
    }
    

    The CI userguide is a good help in this : http://www.codeignitor.com/user_guide/database/

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

Sidebar

Related Questions

I've spent a few hours searching for this, and can't find it, so I'm
I've spent hours searching the web for an answer to this question... Here's what
I've spent the past few hours searching, but can't seem to find the answer.
I've spent a couple of hours searching about this error, and I have tested
I've spent a lot of hours searching and reading similar posts, but none of
First, forgive me if this has been answered already. I spent a few hours
I've spent the last several hours searching the web, and I can't figure this
I hope this is a relatively easy problem although I have spent hours websearching
this may sound funny, but i spent hours trying to recreate a knob with
I've spent hours reading up about AppDomains, but I'm not sure they work quite

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.