This is very strange problem. I've defined two fields to be unique in a table and they can be null if no values are filled into those fields of the table for a particular row. Now after few queries I evaluate the values for those fields and update the fields of the table through an update query. The query results in zero afftected rows.
Is it because of unique key defined on two of them??
Last edited by dude81 on Mon Feb 26, 2007 9:25 am, edited 1 time in total.
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
The following is the table structure
[syntax="sql"]
CREATE TABLE `info` (
`id` bigint(8) NOT NULL auto_increment,
`name` varchar(255) collate latin1_general_ci default NULL,
`user_id1` decimal(10,2) default NULL,
`user_id2` decimal(10,2) default NULL,
`server_id1` decimal(10,2) default NULL,
`server_id2` decimal(10,2) default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`,`server_id1`,`server_id2`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=1
Before the update query I insert user values of the numbers then I pass the same to a function which will identify corresponding server ids and then I update the same table with following query.
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
http://dev.mysql.com/doc/refman/5.1/en/mysql-affected-rows.html wrote:For UPDATE statements, if you specify the CLIENT_FOUND_ROWS flag when connecting to mysqld, mysql_affected_rows() returns the number of rows matched by the WHERE clause. Otherwise, the default behavior is to return the number of rows actually changed.
I guess you haven't set CLIENT_FOUND_ROWS and the query actually didn't change a value.
...or the query fails and you have no error handling in your script.
Oops there is no such function in php as mysql_real_connect. It is a function f or C I believe. I didn't know where to set the flag. I didn't set the flag still..... Sorry I was looking at my new problem(PHP5:SOAP) which is perhaps bigger than this.
I'm afraid the query doesn't work directly on mysql through commandline also. Forget about php executing it.
It says affected rows zero. Is it becuase of the decimal structure