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.

General Questions /

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

SQL table modified outside CMS


Reply


2 Posts   1078 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");