Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

DB field `Index`


Reply

2 Posts   1398 Views

Avatar
xmedeko

30 May 2007 at 11:07am Community Member, 94 Posts

Hi,

I have made a db field caled `Index`:

static $db = array(
       'Index' => 'Int',
       );

Then rebuild DB makes an error:

FATAL ERROR: DATABASE ERROR: Couldn't run query: INSERT INTO `XEArticlePage_Live` (ID,Date, Index, ArticleFileID) SELECT ID,Date, Index, ArticleFileID FROM `XEArticlePage` | You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Index, ArticleFileID) SELECT ID,Date, Index, ArticleFileID FROM `XEArticl' at line 1
At line 186 in /var/www/xebidy/sapphire/core/model/Database.php

The SQL Query should look like this

INSERT INTO `XEArticlePage_Live` (`ID`,`Date`, `Index`, `ArticleFileID`) SELECT `ID`,`Date`, `Index`, `ArticleFileID` FROM `XEArticlePage`

I guess this field can make even more problems, so I am going to rename it.

Avatar
Ingo

30 May 2007 at 9:30pm Forum Moderator, 801 Posts

"Index" is a reserved SQL-name, and should be properly quoted. As you said, it's best to avoid those naming-problems by choosing something less common :)
I've added a bug for it in our issue-tracker.