ADODB_Exception Duplicate Entry error

Permalink
Hello, I'm getting a fatal error whenever adding a new block. This is an issue that has appeared after upgrading to 5.4.1.1

Fatal error: Uncaught exception 'ADODB_Exception' with message 'mysql error: [1062: Duplicate entry '258-66' for key 1] in EXECUTE("insert into CollectionVersionBlockStyles (cID, cvID, bID, arHandle, csrID) values ('66', '11', '258', 'Main', 0)") ' in public_html/concrete/libraries/3rdparty/adodb/adodb-exceptions.inc.php:78 Stack trace: #0 public_html/concrete/libraries/3rdparty/adodb/adodb.inc.php(1037): adodb_throw('mysql', 'EXECUTE', 1062, 'Duplicate entry...', 'insert into Col...', false, Object(ADODB_mysql)) #1 /public_html/concrete/libraries/3rdparty/adodb/adodb.inc.php(993): ADOConnection->_Execute('insert into Col...') #2 /public_html/concrete/libraries/database.php(73): ADOConnection->Execute('insert into Col...', Array) #3 [internal function]: Database->__call(Array, Array) #4 /public_html/concrete/models/block.php(404): Database->Execute('Execute', Array) #5 /public_html/concrete/startup/process.php(624): Block->alias('insert in /public_html/concrete/libraries/3rdparty/adodb/adodb-exceptions.inc.php on line 78

I've found a number of similar problems in the forums but none of their fixes have worked yet. Any ideas?

netclickMe
View Replies: View Best Answer
netclickMe replied on at Permalink Reply
netclickMe
Problem resolved thanks to this post:http://www.concrete5.org/community/forums/installation/error-upgrad...

Though the information at that link is out of date due to the recent change in the Concrete5 database table names. So instead of the table 'collectionversionblockstyles' this is table name CollectionVersionBlockStyles. Here are the mysql edits I made.

Deleted table: CollectionVersionBlockStyles
Then ran this mysql query.
CREATE TABLE IF NOT EXISTS `CollectionVersionBlockStyles` (
  `bID` int(10) unsigned NOT NULL DEFAULT '1',
  `cID` int(10) unsigned NOT NULL DEFAULT '1',
  `cvID` int(10) unsigned NOT NULL DEFAULT '0',
  `arHandle` varchar(255) NOT NULL,
  `csrID` int(10) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`bID`,`cID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;,


and this one
ALTER TABLE `CollectionVersionBlockStyles`
  DROP PRIMARY KEY,
   ADD PRIMARY KEY(
     `cID`,
     `cvID`,
     `bID`,
     `arHandle`);
stromberg replied on at Permalink Best Answer Reply
stromberg
Hi, good to see that you were able to fix the error!

Just wanted to add that the table names haven't changed, but it rather depends on whether your database runs on a system that is case-sensitive (e.g. Linux/UNIX) or case-insensitive (e.g. Windows) (and it might also have to do with the MySQL-specific setting "lower case table names"):

For example, on my Xampp setup on Windows XP, all table names are lower-case; and on my webhost's linux server all table names are in "camel-case" as in your description.

I'm still not sure if that's critical, but I would also change the "DEFAULT '1'" part of `cID` and `bID` to '0':
ALTER TABLE `CollectionVersionBlockStyles`
  MODIFY COLUMN `bID` INTEGER UNSIGNED NOT NULL DEFAULT 0,
  MODIFY COLUMN `cID` INTEGER UNSIGNED NOT NULL DEFAULT 0;


Cheers!
stromberg
netclickMe replied on at Permalink Reply
netclickMe
Camel-Case! Ha, I never knew there was a term for that. I picked up that naming technique from writing Action Script for flash. Thanks for the update. Also on the point that you're using Xampp. I've been reviewing Wamp and Xampp. Xampp seems to be the best but I'm going to give the "Uniform Server" a whirl. Just a streamline of thought... Thanks again
alligatorlegs replied on at Permalink Reply
Hi -- I've been having a similar problem that nobody can help me fix: http://www.concrete5.org/community/forums/customizing_c5/error-mess...

Was wondering if you know how to deal with this duplicate key problem re: page attributes? I am very clueless, not even sure where/how to edit the database, if in fact that's what is required...
monobasic replied on at Permalink Reply
monobasic
netclickMe: your the man!
Had the same problem with a site, your queries solved my problem - many thanks for posting these!