Question

I'm getting an odd result, the following is the state of the mysqli object after a simple update query:

"UPDATE charstate SET name = '-', type = 'The Homemaker' WHERE gameno = 1"

As you see the affected_rows = -1 but... the info is "Rows matched: 3 Changed: 3 Warnings: 0" And the query has updated the database. I am using mysqli->affected_rows to check the success which is returning -1 and failing my test but that is incorrect.

Any ideas?

mysqli object {
  affected_rows => (int) -1
  client_info => (string) mysqlnd 5.0.10 - 20111026 - $Id: 
  client_version => (int) 50010
  connect_errno => (int) 0
  connect_error => null
  errno => (int) 0
  error => (string)
  error_list => array(0)
  field_count => (int) 0
  host_info => (string) 127.0.0.1 via TCP/IP
  info => (string) Rows matched: 3  Changed: 3  Warnings: 0
  insert_id => (int) 0
  server_info => (string) 5.5.27
  server_version => (int) 50527
  stat => (string) Uptime: 11431  Threads: 6  Questions: 542  Slow queries: 0  Opens: 52  Flush tables: 1  Open tables: 2  Queries per second avg: 0.047
  sqlstate => (string) 00000
  protocol_version => (int) 10
  thread_id => (int) 114
  warning_count => (int) ...
Was it helpful?

Solution

This behavior above appears when using "root" as the mysql user login (without password). When using another user the affected_rows is correctly given.

Weird! Seems this is a bug of some sort in mysql or PHP. I don't know which or how to report that to whom.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top