At 8:13 PM +0100 5/3/01, VVM Ravikumar Sarma Chengalvala wrote:
>I am using C_API for accessing data from MYSQL.
>mysql_query() function returns the following values:
>0 if the query is successful
>-1 if the query fails.
No. It returns 0 if the query is successful and NON-ZERO if it
fails. You cannot count on the non-zero value being -1.
>At the same time mysql-C_API documentation specifies
>that it returns a non zero number if query is a
>failure.Does the function return any other values
>other than -1 if the query fails?
Don't test for -1. Test for non-zero.
>If I use the mysql_query() for INSERT or UPDATE
>statements I am facing the following problem:
>If the database column value I am trying to update is
>the same as the the value already existing in the
>database,then the mysql_query() returns 0 and the
>mysql_affected_rows() returns zero.
>It will be good if mysql_query either returns -1 for
>this case as the value being updated is same as that
>of existing one.
Try setting the CLIENT_FOUND_ROWS option in your mysql_real_connect()
call when you connect to the server and see what happens..
Paul DuBois, paul@stripped