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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:48:14+00:00 2026-06-18T17:48:14+00:00

Using MySQL alone – If I make a basic update to a table like

  • 0

Using MySQL alone – If I make a basic update to a table like this:

UPDATE `SOMETABLE` SET `NAME` = 'John' WHERE `ID` = 1;

And the value of NAME = ‘John‘ was already ‘John‘ – in other-words – nothing is new, nothing to update. MySQL returns “Affected rows: 0 (Query took 0.0007 sec)“

If I make the same call – now using CodeIgniter – and then retrieve the affected rows like this:

$data = array(
               'NAME' => 'John'
            );

$this->db->where('ID', 1);
$this->db->update('SOMETABLE', $data); 
$affect = $this->db->affected_rows();

echo $affect; // $affect echos 1

$affect ends up equaling 1.
I haven’t got a problem with this – I just expected that if there was nothing to update – that codeigniter would behave the same way as MySQL and not edit something that does not need to be updated, and return 0 for affected_rows().

  • Have I got this wrong some way?
  • Is codeigniter overwriting ‘John‘? or not?
  • 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-18T17:48:16+00:00Added an answer on June 18, 2026 at 5:48 pm

    Try getting the query that CodeIgniter is running using the following code:

    $this->db->last_query();
    

    Also post the query you are using to interact with MySQL, just to confirm that the exact same query is being run.

    CodeIgniter does have a hack for MySQL that adjusts the reporting of affected rows, however I was under the impression it was only for DELETE queries. If you look at system/database/drivers/mysql/mysql_driver.php or system/database/drivers/mysqli/mysqli_driver.php (whichever driver you are using and look at the variable var $delete_hack = TRUE;. Adjusting that might impact your result, could be worth a try?

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

Sidebar

Related Questions

I've found a few answers for this using mySQL alone, but I was hoping
I am using this basic mySQL query which works great: $sql = SELECT *
Using MySQL, I have a simple table that logs the IP Address that users
Using MySQL, I have three tables: projects : ID name 1 birthday party 2
Currently using MySQL version 5.1.6 This is my first real world build and so
I'm building an application using Java and Mysql 5.1. i would like to know
Using MySQL I have table of users, a table of matches (Updated with the
I am using MySql and PHP. I have a table groupXmembers that holds members
I would like to find all duplicate records by name in a customer table
I have a large table in mysql, about 1 million records. I'm using a

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.