lime icon

Phosphorus and Lime

A Developer's Broadsheet

This blog has been deprecated. Please visit my new blog at klenwell.com/press.
MySQL notes
A couple notes:

1. affected rows

In updating a record using PHP/MySQL where the data is not actually changed, PHP will return 0 rows affected. To get around this, there is a flag that can be set when establish the db connection. Details here:

http://www.php.net/manual/en/function.mysql-affected-rows.php#33509

2. MySQL 'INSERT ... ON DUPLICATE KEY UPDATE'

I wrote a function that does this the long way by trying to select the row then inserting or updating based on the result. This is probably much more efficient. Details here:

http://dev.mysql.com/doc/refman/4.1/en/insert-on-duplicate.html

keywords: php, mysql, insert, update, affected, rows, duplicate