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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:05:37+00:00 2026-05-30T12:05:37+00:00

This is something I used to do in Java, I was wondering if there

  • 0

This is something I used to do in Java, I was wondering if there is an equivelant in PHP.

In Java, I’d do something like this (pseudo only as I’ve gotten rusty in the last year or so):

preparedStatement = new StringBuilder("SELECT something FROM somewhere");
ResultSet rs = preparedStatement.executeQuery();
while(rs.next())
{
    if (someTest)
    {
        rs.updateRow[1]="someNewValue";
    }
}

This is wide of the mark syntactically (and I bet it won’t compile) but I hope it explains the kind of thing I was able to do. Not sure if it saved an actual DB query from being run but it did make my code alot cleaner.

So in PHP, I have something like this:

$query = "SELECT something FROM somewhere";
$result = mysql_query($query, $db);
while ($row = mysql_fetch_assoc($result))
{
    if (someTest)
    {
        //how can I update this row without coding another query?
    }
}

Is there an equivelant to this in PHP?

I’m using the vanilla mysql db methods, not mysqli or that other one (pod or something?) but I think I’d be safe to use mysqli on our servers if I need to.

Any help 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-30T12:05:38+00:00Added an answer on May 30, 2026 at 12:05 pm

    Nope, you could however use mysql_fetch_object with a custom classname, and define a save() method on it that will run the update query for you. Keeps the logic out of the loop and in a Model for that data. Or use an full-blown ORM library which does this kind of thing.

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

Sidebar

Related Questions

In our code we used to have something like this: *(controller->bigstruct) = ( struct
This is something that I think would be very useful. Basically, I'd like there
I'm used to developing Java programs in Eclipse, where I can type something like...
I've discovered this idiom recently, and I am wondering if there is something I
Been a while since I've used C++. Can I do something like this?: for
I haven't used java in awhile and I am trying to do something like
Some background; I'm quite used to PHP, and I always used something like 'connect.ini'
This is something I've pondered over for a while, as I've seen both used
I saw something once for wrappers used to do this but it asked for
Something like var life= { users : { guys : function(){ this.SOMETHING.mameAndDestroy(this.girls); }, girls

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.