NLT Posted August 7, 2011 Share Posted August 7, 2011 Okay, how would I go around doing a core when on another page I want something like so it can lookup the whole table, so if I wanted online_users I could use something like this: $core-> new Core(); echo $server_status['online_users']; And if I wanted something like server_name I could use something like $core-> new Core(); echo $server_status['server_name']; Link to comment https://forums.phpfreaks.com/topic/244135-classcore/ Share on other sites More sharing options...
NLT Posted August 7, 2011 Author Share Posted August 7, 2011 Sorry, can't edit. So merge this please. What I want to add is that the table name is server_status Link to comment https://forums.phpfreaks.com/topic/244135-classcore/#findComment-1253772 Share on other sites More sharing options...
ignace Posted August 7, 2011 Share Posted August 7, 2011 Something like this? $onlineUsers = $system->getModule('online_users'); print '<pre>' . $onlineUsers->toString() . '</pre>'; $server = $system->getModule('server'); print '<pre>' . $server->toString() . '</pre>'; Link to comment https://forums.phpfreaks.com/topic/244135-classcore/#findComment-1253786 Share on other sites More sharing options...
NLT Posted August 7, 2011 Author Share Posted August 7, 2011 No. I mean I need the core.php file (code) for that. So something like: class Core { { function server_status() mysql_query("SELECT * FROM server_status") // * being value } } Link to comment https://forums.phpfreaks.com/topic/244135-classcore/#findComment-1253793 Share on other sites More sharing options...
NLT Posted August 7, 2011 Author Share Posted August 7, 2011 Anybody? Link to comment https://forums.phpfreaks.com/topic/244135-classcore/#findComment-1253812 Share on other sites More sharing options...
ignace Posted August 7, 2011 Share Posted August 7, 2011 class Core { public function server_status($what) $what = mysql_real_escape_string($what); mysql_query("SELECT " . $what . " FROM server_status") // * being value } } Or are you just after how to access an object like an array? class Core implements ArrayAccess { public function offsetGet($offset) { switch ($offset) { case 'server_status': return $this->getServerStatus(); } } public function offsetSet($offset, $value) {/*dummy*/} public function offsetExists($offset) { return in_array($offset, array('server_status', ..)); } public function offsetUnset($offset) {/*dummy*/} } $core = new Core(); print $core['server_status']; Link to comment https://forums.phpfreaks.com/topic/244135-classcore/#findComment-1253856 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.