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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:51:13+00:00 2026-05-25T13:51:13+00:00

How do I tell when a MySQL UPDATE was successful versus actually updated data?

  • 0

How do I tell when a MySQL UPDATE was successful versus actually updated data?

Example:

TABLE
id    city_name
1     Union
2     Marthasville

If I run the following:

$data = array('city_name', 'Marthasville');

//update record 2 from Marthasville to the same thing, Marthasville. 
$this->db->where('id', 2);
$this->db->update('table', $data);

if($this->db->affected_rows() > 0)
{
    //I need it to return TRUE when the MySQL was successful even if nothing was actually updated.
    return TRUE;
}else{
    return FALSE;
}

This will return TRUE every time the UPDATE statement is successful, but FALSE when no rows were actually updated.

I need it to return TRUE every time the UPDATE statement was successfully executed even if it doesn’t actually change any records.

  • 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-25T13:51:13+00:00Added an answer on May 25, 2026 at 1:51 pm

    Have a look at mysql_affected_rows()

    It should tell you if anything was actually updated as opposed to nothing was successfully updated resulting in a return of true.

    php.net says:

    mysql_affected_rows()

    Returns the number of affected rows on success, and -1 if the last
    query failed.

    You could use the following to achieve your desired results:

    if($this->db->affected_rows() >= 0){ }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to update a DB table with the following structure: user_id, group_id,
I am new to MySQL and PHP(as you can probably tell) and I was
Can any body tell me how can I store Java Date to Mysql datetime...?
Can anyone tell me how to insert special characters into a MySQL database? I've
Two libraries for Mysql. I've always used _mysql because it's simpler. Can anyone tell
We want to store product prices and weight (kg/pound) in MySQL. Can somebody tell
I have some CSV data files that I want to import into mySQL. I
I ve installed MySQL (last update). I need to code, that ll create &
I have a simple mysql_query() update command to update mysql. When a user submits
In my MySQL database, I have the following column type. Field | Type |

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.