Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » DB field `Index`

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

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

Page: 1
Go to End
Author Topic: 1360 Views
  • xmedeko
    Avatar
    Community Member
    94 Posts

    DB field `Index` Link to this post

    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.

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: DB field `Index` Link to this post

    "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.

    1360 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.