Wouldn't "INSERT OR REPLACE" do that for you? (which by the way, has to be
one of the coolest features in SQLite of all!)

http://www.sqlite.org/lang_insert.html


Doug

> -----Original Message-----
> From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-
> boun...@sqlite.org] On Behalf Of yogibabu
> Sent: Saturday, September 12, 2009 11:51 AM
> To: sqlite-users@sqlite.org
> Subject: [sqlite] one liner for insert or update ?
> 
> 
> my dream is to be able do it like that:
> <?php
> $pdo = new PDO('sqlite:database.DB3');
> $pdo->query("INSERT UPDATE table SET value1='somedata',
> value2=somedata,
> id=$getid ")
> ?>
> 
> when $getid contains data (a number of course) then an update is
> performed,
> otherwise if it is null then database engine ignores `id` valule
> without any
> notification and INSERT is performed with adding new id...
> --
> View this message in context: http://www.nabble.com/one-liner-for-
> insert-or-update---tp25416164p25416164.html
> Sent from the SQLite mailing list archive at Nabble.com.
> 
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to