public function create($tableName, $userInput) {
$this->db->insert($tableName, $userInput);
return $this->db->affected_rows();
}
As you see, $this->db->affected_rows(); is not referencing to any specific resource/executed statement.
Does affected_rows() return latest affected_rows() in the database generally? In other words, if i have 50 users calling create(…) function, how does codeigniter associate each affected_rows() to its executed statement?
This questions is codeigniter specific.
In codeigniter
system/database/drivers/mysql/mysql_driver.phpat line 337:Which basically means there are no difference between CodeIgniter and standard PHP function http://php.net/manual/en/function.mysql-affected-rows.php
It returns the number of rows which were affected by the last query, so if you have problems and it’s always returning 1, it means codeigniter iterates your query, a quick workaround for this to work is to use your own query with `$this->db->query();’