Jump to:

22977 Posts in 11806 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » SQL table modified outside CMS

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 993 Views
  • Exiler
    Avatar
    Community Member
    2 Posts

    SQL table modified outside CMS Link to this post

    Hello,

    I've got some outside modifed tables in database, and not need to modify that tables in CMS, but need to print out data in templates. So i'm stuck in creating queries for that tables. I use simple SS like query:

    return DataObject::get("tradinghours");

    And got and error:

    [User Error] Bad class to singleton() - tradinghours
    if(!class_exists($className)) user_error("Bad class to singleton() - $className", E_USER_ERROR);

    When trying to more complicated way fom sqlquery example:

    $sqlQuery = new SQLQuery();
    $sqlQuery->select = array('Name', 'Opening', 'Closing');
    $sqlQuery->from = "TradingHours";
    //$sqlQuery->where = "";

    //$rawSQL = $sqlQuery->sql();

    $result = $sqlQuery->execute();

    I've stuck into an error:

    [Warning] implode() [function.implode]: Invalid arguments passed
    $text .= " FROM " . implode(" ", $sqlQuery->from);

    Need assistance to figure out. Thank you.

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: SQL table modified outside CMS Link to this post

    Try this:

    $sqlQuery->from = array("TradingHours");

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