I have a PHP class which is supposed to return an array to where the object is instantiated. I have tried to figure out what the problem is but I can't seem to see it. Can anyone see where I have gone wrong here or point me in the right direction? Thanks
Here is the class (within a file called 'feeds.php.)
class updateFeed {
public function index() {
$db = JFactory::getDBO();
$query = "SELECT * FROM tweets";
$db->setQuery($query);
$result = $db->loadObject()
if(strtotime($result->date_added) <= time() - 3200) {
$this->updateTweets();
}
$query = "SELECT * FROM tweets ORDER BY tweet_date DESC LIMIT 0, 3";
$db->setQuery($query);
$results = $db->loadObjectList();
$tweet_db = array();
foreach($results as $result) {
$tweet_db[] = array(
'title' => $result->title,
'text' => $result->text,
'tweet_date' => $result->tweet_date
);
}
return $tweet_db;
}
And here is where the object is instantiated (in the index.php file):
include('feeds.php');
$tweet_dbs = new updateFeed;
print_r($tweet_dbs);
The print_r in the index file shows 'updateFeed Object ( ) '. Thanks in advance.
print_r($tweet_dbs->index());as you never call the class-method.