2011-12-04 11 views
0

行が存在するかどうかをチェックするSQLクエリを実行します。タプルがある場合はINSERT INTOを設定します。その他のUPDATEを設定します。ユーザーIDは主キーです。 PHPで単一のクエリで直接実行しようとしました...可能ですか?私はどうにかして存在しないコマンドを使用することができますか?が属性に存在しません

enter code here 

$query = 'INSERT INTO Settings SET 
      userID = '.$uid.', 
     visibility = -1, 
     notify_icon = true, 
     notify_connect_friend = true, 
     notify_near_friend = true, 
     ringer = true, 
     vibration = true 
    '; 
$query = 'UPDATE Settings SET 
     visibility = '.$visibility.', 
     notify_icon = '.$notify_icon.', 
     notify_connect_friend = '.$notify_connect_friend.', 
     notify_near_friend = '.$notify_near_friend.', 
     ringer = '.$ringer.', 
     vibration = '.$vibration.' 
    WHERE 
     userID = '.$uid.' 
    '; 
+0

MySQL置換(ANSI標準ではありません)とみなしましたか?http://dev.mysql.com/doc/refman/5.1/en/replace.html – Jay

答えて

0

REPLACE mysqlステートメントを参照してください。

関連する問題