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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

SQL table modified outside CMS


Go to End


2 Posts   1720 Views

Avatar
Exiler

Community Member, 2 Posts

5 April 2010 at 8:38am

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.

Avatar
Hamish

Community Member, 712 Posts

5 April 2010 at 10:07am

Try this:

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