during my 7-year career as a programmer, i've interacted with sql via an orm most of the time. one feature from laravel's eloquent orm that i find particularly useful is its updateorinsert()...
在我7年的编程中,我主要用orm与sql交互。laravel的eloquent orm有个实用的updateorinsert()方法,但wordpress中没有类似功能,因为post_name不是主键也没有唯一约束。为解决这个问题,我用两个sql语句:先更新已有行,再在没有匹配行时插入新行。这方法适合一次性迁移,不需要存储过程或应用逻辑。