in reply to Altering SQL code from Update to Insert
You still have to write the matching UPDATE and INSERT, but it's written so you can switch between the two easily:
$upd_sql = "UPDATE table SET [Field1]=?, [Field2]=?, [Field3]=? where +Field0=?"; $ins_sql = "INSERT INTO table ( [Field1], [Field2], [Field3], [Field0] + ) VALUES ( ?, ?, ?, ? )"; $sth = $dbh->prepare($exists ? $ins_sql : $upd_sql); $sth->execute( 'stringvalue', numericvalue, booleanvalue, index, );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Altering SQL code from Update to Insert
by bradcathey (Prior) on Dec 11, 2004 at 18:33 UTC | |
by ikegami (Patriarch) on Dec 11, 2004 at 18:53 UTC |