<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Forum posts to 'Extending and hacking'</title>
		<link>http://www.silverstripe.com/extending-hacking-silverstripe-forum/</link>
		

		
		<item>
			<title>Re: Querying Database via a Class function from _config.php</title>
			<link>http://www.silverstripe.com/extending-hacking-silverstripe-forum/show/73649?showPost=78454</link>
			<description>just wondering if you go this working, cos i would like to be able to select a theme from inside the cms as well...&lt;br /&gt;&lt;br /&gt;if you did could you post the code?&lt;br /&gt;&lt;br /&gt;thanx&lt;br&gt;&lt;br&gt;Posted to: Querying Database via a Class function from _config.php</description>
			<pubDate>Mon, 26 May 2008 21:17:30 +1200</pubDate>
			<author>Nick </author>
			<guid>http://www.silverstripe.com/extending-hacking-silverstripe-forum/show/73649?showPost=78454</guid>
		</item>
		
		<item>
			<title>Re: Querying Database via a Class function from _config.php</title>
			<link>http://www.silverstripe.com/extending-hacking-silverstripe-forum/show/73649?showPost=74367</link>
			<description>Dio&lt;br /&gt;Thanks for that.&lt;br /&gt;I can get the get_current_theme() code to run, my issue is querying the Config table for the value of Theme. &lt;br /&gt;At the very least what I want to do is &quot;SELECT * FROM Config&quot; and then get the value of Theme from the 1 row which is returned (as I only have one row..)&lt;br /&gt;&lt;br /&gt;But how to do it from my Config.php class function without the errors listed on original post?&lt;br /&gt;&lt;br&gt;&lt;br&gt;Posted to: Querying Database via a Class function from _config.php</description>
			<pubDate>Sat, 17 May 2008 08:54:06 +1200</pubDate>
			<author>Spencer Crocker</author>
			<guid>http://www.silverstripe.com/extending-hacking-silverstripe-forum/show/73649?showPost=74367</guid>
		</item>
		
		<item>
			<title>Re: Querying Database via a Class function from _config.php</title>
			<link>http://www.silverstripe.com/extending-hacking-silverstripe-forum/show/73649?showPost=74142</link>
			<description>AFAIK you can only do&lt;br /&gt;&lt;br /&gt;Config::get_current_theme(); &lt;br /&gt;&lt;br /&gt;if you made get_current_theme() a static method.&lt;br /&gt;&lt;br /&gt;See for example: http://theserverpages.com/php/manual/en/language.oop5.static.php&lt;br /&gt;&lt;br /&gt;Be aware though that static vars/methods are tied to the class rather than to an instance of it.&lt;br&gt;&lt;br&gt;Posted to: Querying Database via a Class function from _config.php</description>
			<pubDate>Fri, 16 May 2008 21:41:29 +1200</pubDate>
			<author>Dieter Orens</author>
			<guid>http://www.silverstripe.com/extending-hacking-silverstripe-forum/show/73649?showPost=74142</guid>
		</item>
		
		<item>
			<title>Querying Database via a Class function from _config.php</title>
			<link>http://www.silverstripe.com/extending-hacking-silverstripe-forum/show/73649</link>
			<description>Hi, &lt;br /&gt;I would like to shift the theme selection process to a Page in the CMS.&lt;br /&gt;I have the following;&lt;br /&gt;&lt;br /&gt;class Config extends Page {&lt;br /&gt;&lt;br /&gt;	static $db = array(&lt;br /&gt;		'Theme' =&amp;gt; 'Text',&lt;br /&gt;	);&lt;br /&gt;	&lt;br /&gt;	function get_current_theme() {&lt;br /&gt;		$result = DataObject::get_one('Config');&lt;br /&gt;		return $result-&amp;gt;Theme;&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;The function returns the value of Theme if I call $get_current_theme from a template but if I call it from mysite/_config.php using&lt;br /&gt; &lt;br /&gt;Config::get_current_theme();&lt;br /&gt;&lt;br /&gt;I get the following errors, which I assume are because I am ahead of the class construction of SS.&lt;br /&gt;&lt;br /&gt;Warning: ClassInfo::dataClassesFor() no parents for Config in sapphire\core\ClassInfo.php on line 49&lt;br /&gt;&lt;br /&gt;Warning: Invalid argument supplied for foreach() in sapphire\core\ClassInfo.php on line 50&lt;br /&gt;&lt;br /&gt;Fatal error: DataObject::buildSQL: Can't find data classes (classes linked to tables) for Config in sapphire\core\model\DataObject.php on line 1334&lt;br /&gt;Can I achieve the same DB query using the SQLQuery function? If so how, I can't work out the syntax from the doco or api pages.&lt;br&gt;&lt;br&gt;Posted to: Querying Database via a Class function from _config.php</description>
			<pubDate>Thu, 15 May 2008 21:34:43 +1200</pubDate>
			<author>Spencer Crocker</author>
			<guid>http://www.silverstripe.com/extending-hacking-silverstripe-forum/show/73649</guid>
		</item>
		

	</channel>
</rss>
