If this is not safe enough, send an UPDATE query, get the affected row count, if 0, send an INSERT.