RE: [PHP-DB] UPDATE instead of INSERT INTO

From: Date: Tue, 08 Sep 2009 23:29:10 +0000
Subject: RE: [PHP-DB] UPDATE instead of INSERT INTO
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-46476@lists.php.net to get a copy of this message
http://dev.mysql.com/doc/refman/5.0/en/replace.html Or as previously mentined: http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html > > -----Original Message----- > > From: Ron Piggott [mailto:ron.php@actsministries.org] > > Sent: Saturday, September 05, 2009 1:19 PM > > To: php-db@lists.php.net > > Subject: [PHP-DB] UPDATE instead of INSERT INTO > > > > I made an application which lets users rate web site content. > > At the heart of the application is this mySQL query: > > > > INSERT INTO ratings ( > > reference , content_type , > > content_reference , > > language , ip_address , > > rating_timestamp , rating > > ) VALUES ( NULL , > > '$content_type','$content_reference' , '$language', > > '$ip_address', NOW( ) , '$user_rating' ); > > > > I am wondering if there is a way to check if the user has > > already voted (IE If there is already a matching record with > > the same content_type, content_reference, language, > > ip_address values) so all that happens is an UPDATE to the > > rating field? > > > > Ron

« previous php.db (#46476) next »