cakephp logo

HABTM error 512 duplicate sql in CakePHP 1.2

While trying to submit a $hasAndBelongsToMany (HABTM) related form under cakephp (1.2 rev 6311) I would get the following SQL Error :-

  • Warning (512): SQL Error: 1062: Duplicate entry '4-1' for key 1 [CORE/cake/libs/model/datasources/dbo_source.php, line 440]

The solution for this was to add the following line to the beginning of the foreach in the cake/libs/model/model.php (between lines 1284/1285) :-

Show Plain Text
PHP code
  1. $newValues = array();

You could also download either the latest CVS or nightly build which has this and other fixes already implemented.

Related Article:
Filed under: Cakephp  Tags: Habtm

0 Responses to “HABTM error 512 duplicate sql in CakePHP 1.2”

Sorry, comments have been closed for this post.