Welcome Guest, Not a member yet? Register   Sign In
Affected Rows won't work when using batch insert/update
#1

[eluser]axelitus[/eluser]
Hi, as the post title says the function to get the affected rows doesn't work when using the batch insert or update functions.

I'm using CodeIgniter 2.0.2 Reactor

Let's say we have the following array:
Code:
$data = array(
  array(
    'username' => 'axelitus',
    'name' => 'Axel'
  ),
  array(
    'username' => 'test_user',
    'name' => 'Test'
  )
)

And now we try to insert it with the insert_batch() function from the DB class:
Code:
$this->db->insert_batch ('users', $data );

The function works as expected inserting the data (if the primary key for one record already exists this functions returns an error as expected). But when I try to get the affected rows count all I get is a zero although the records were inserted correctly.
Code:
$affected_rows = $this->db->affected_rows ();
var_dump($affected_rows);

Output:
Code:
int(0)

This doesn't seem right at all and it also happens with the update_batch() function.
If anyone knows what is happening... or if this is a bug/error to post it in the bug tracker...


Messages In This Thread
Affected Rows won't work when using batch insert/update - by El Forum - 04-11-2011, 08:52 AM
Affected Rows won't work when using batch insert/update - by El Forum - 04-11-2011, 10:14 AM
Affected Rows won't work when using batch insert/update - by El Forum - 04-11-2011, 12:56 PM
Affected Rows won't work when using batch insert/update - by El Forum - 04-11-2011, 02:04 PM
Affected Rows won't work when using batch insert/update - by El Forum - 04-11-2011, 03:22 PM
Affected Rows won't work when using batch insert/update - by El Forum - 10-19-2012, 08:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB