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

  • Home
  • SEARCH
  • 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 7525187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:28:17+00:00 2026-05-30T03:28:17+00:00

I have a question about PHP foreach loops. I’m using it in Codeigniter. Basically

  • 0

I have a question about PHP foreach loops. I’m using it in Codeigniter.

Basically I have a list of items in a db and I’m using a foreach loop to run a script on each item in the db until the script has been run on every item.

My question is: If I had, for example, 45 items in the database and then initiated the loop, what would happen if additional items were added to the database list while the loop was still running, thus making a bigger list of items to be looped over?

Would it either:
Run all the items that were in the loop when it was initiated (in this case, 45).
or
Run all the items in the loop and when it gets down to the end (at number 45) continue to run the script on the additional ones I added after the loop was initiated.

I can’t seem to find any answers for this, any info is most appreciated

  • 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-30T03:28:18+00:00Added an answer on May 30, 2026 at 3:28 am

    When you fetch all items from the db with CodeIgniter, it puts the results in an result object or array, depending if you use $this->db->result(); or $this->db->result_array();

    So when you loop over this result, any new records won’t show up in this object or array. Only when you fire a new query, any new rows will be added to the result.

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

Sidebar

Related Questions

Quick question about general MVC design principle in PHP, using CodeIgniter or Kohana (I'm
I have written a script using my local PHP 5.3 installation making use of
Using PHP 5.x and MySQL 5.x So I asked a question yesterday about the
I have a question about PHP and the use of pointers and variables. The
I have a question about the PHP syntax.Below is the php code: $err =
I have an interesting question about the way PHP evaluates boolean expressions. When you
I'm building this website and I have basically two questions about this page: http://sites.publishyours.com.br/silviamecozzi/pt/obra/deserto_das_palmas.php
I have question about normalization. Suppose I have an applications dealing with songs. First
I have question about interpreting strings as packed binary data in C++. In python,
i have question about YAJLiOS parser... I have next json data : {{ body

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.