2
基本上,我想在MySQL中实现与ON DUPLICATE KEY一样的功能。Cakephp模型类中的save方法是否可以选择创建和更新记录?
这里是一个人为的例子:
$rec = array('Foo' => array( 'id' => 999, // Assume there isn't already a record with this id 'website' => 'google' )); $this->Foo->save($rec); // save with different 'website' value $rec['Foo']['website'] = 'stackoverflow'; $this->Foo->save($rec);
是否最后一行更新创建短短的几行了记录?
谢谢,彼得。你达人。 – allyourcode 2009-07-10 03:20:21