Editor - DB field names with embedded spaces

Editor - DB field names with embedded spaces

davistomdavistom Posts: 2Questions: 0Answers: 0
edited April 2013 in Editor
I just downloaded the Editor trial version and built some pages with editable datatables for several tables in an existing MySql database. All looked good till I got to a table which has a column name with embedded spaces. The resulting page fails to retrieve the requested table data with a MySql syntax error near the select list. I used backtick quotes on all occurrences of the subject field name in the client and server ajax scripts and tried again with the same result. Am I doing something wrong or am I trying to do something that is not permitted?

Replies

  • allanallan Posts: 60,962Questions: 1Answers: 9,939 Site admin
    Sorry for missing this at the time of posting. In theory the Editor DB libraries should allow this without any quoting required, but I think you've hit upon a bug here unfortunately. On the flip side, the fix is actually quite simple - in Query.php the lines:

    [code]
    if ( strpos($identifier, ' as ') !== false ) {
    $alias = strstr($identifier, ' as ');
    $identifier = substr($identifier, 0, - strlen($alias));
    }
    [/code]

    should be:

    [code]
    if ( strpos($identifier, ' ') !== false ) {
    $alias = strstr($identifier, ' ');
    $identifier = substr($identifier, 0, - strlen($alias));
    }
    [/code]

    Then you'll be able to do things like:

    [code]
    Field::inst( 'eng ine', 'engine' )->validator( 'Validate::required' ),
    [/code]

    I'll package this up into the next release. Thanks for flagging it up.

    Regards,
    Allan
  • davistomdavistom Posts: 2Questions: 0Answers: 0
    Thanks.
This discussion has been closed.