470,815 Members | 1,147 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,815 developers. It's quick & easy.

Rows affected?

Hi,

I am executing an update-query. Is there a way I would get a result if there
is a row affected, because if the row isn't affected (product may not exist)
I have to execute a insert-query. This way I could use 1 query (in the
update-case). Else I would always have to execute 2 query's (1 count-query
and 1 insert or update query).

Thnxz...
Jul 16 '05 #1
2 2999
no spam wrote:
Hi,

I am executing an update-query. Is there a way I would get a result if
there is a row affected, because if the row isn't affected (product may
not exist) I have to execute a insert-query. This way I could use 1 query
(in the update-case). Else I would always have to execute 2 query's (1
count-query and 1 insert or update query).

Thnxz...


http://dk.php.net/manual/en/function...ected-rows.php

Should give you a hint.
That it says dk.php.net is only due to the local mirror.

/Andreas
--
Registeret Linux user #292411
Jul 16 '05 #2
thnxz... mysql_affected_rows() was the function. Totally forgot the
mysql-functions...

"Eivind Lie Nitter" <el*@gmx.net> schreef in bericht
news:1fz4bvf.ick75z156nw93N%el*@gmx.net...
Roger Godefroy <godefroy@(nospam)home.nl> wrote:
Hi,

I am executing an update-query. Is there a way I would get a result if there is a row affected, because if the row isn't affected (product may not exist) I have to execute a insert-query. This way I could use 1 query (in the
update-case). Else I would always have to execute 2 query's (1 count-query and 1 insert or update query).

Thnxz...


If you are using MySQL:

mysql_query("update table set bla='bla' where id=17");

if (mysql_affected_rows() == 0) {

mysql_query("insert ...");

}

Should work :)

--
Eivind Lie Nitter
el*@gmx.net
http://ununique.net

Jul 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by RotterdamStudents | last post: by
5 posts views Thread by Chris Stromberger | last post: by
2 posts views Thread by Gnurp Gnarp | last post: by
1 post views Thread by dkode8 | last post: by
3 posts views Thread by Carl K | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.