By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,712 Members | 2,063 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,712 IT Pros & Developers. It's quick & easy.

Rows affected?

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.