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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:51:55+00:00 2026-06-07T23:51:55+00:00

I have a query that’s pulling a list of IDs. Those IDs are in

  • 0

I have a query that’s pulling a list of IDs. Those IDs are in an array and I need to search another table with those IDs. I tried using implode to make those IDs a string that I could use in a where clause but I keep getting this error.

My current code is:

 $query = $this->db->query('
        SELECT *
        FROM system_scoperights
        WHERE user = '. $this->session->userdata('username') .'
    ');

    foreach ($query->result() as $row) {
        $scope = $row->site;
        $data[] = $scope;
    } 
    $dataScope[] = $data;

    $idList = implode(',', $dataScope);   <---- Error Line

    $where = 'WHERE scope_scopes.sc_ID IN '. $idList .'';

I’ve tried different things I found on forums like:

 $idList = implode(',', array_values($dataScope));

and

 $idList = implode(',', join($dataScope));

but none of those work. (I’ve never even heard of the join function)

Thanks in advance for the help.

  • 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-07T23:51:56+00:00Added an answer on June 7, 2026 at 11:51 pm
    $dataScope[] = $data;
    

    but

    $data[] = $scope;
    

    therefore $dataScope has an array inside it’s array. implode only work on one level, so that why you’re getting this error.

    You should note that this is actually possible in SQL:

     SELECT * FROM some_table WHERE id IN (SELECT site FROM another_table WHERE ... )
    

    which would eliminate the entire need for this code.

    That is:

    $where = 'WHERE scope_scopes.sc_ID IN (SELECT site
                                           FROM system_scoperights
                                           WHERE user = '. $this->session->userdata('username') . ')';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query that selects 3 columns from a SQL table, I need
I am using in C# MYsql .I have query that works if I run
I have a query that successfully grabs the unique products from my products table
I have a query that is pulling users who liked a specific object from
I have a query that should request the top X number of records using
I have a query that looks like this: using (MyDC TheDC = new MyDC())
I have this query that retreives a list of id's + NAME: $sql =
Lets say I have query that gets following List Item Objects with Set of
We have a query that runs off a fairly large table that unfortunately needs
I have query that looks like this declare @tmpTable Table(id int) insert into @tmpTable(id)

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.