1

Wordpress guy attempting to help out a client with a Joomla project he's stuck on (favor time basically), and I'm hitting a wall. I believe I'm doing my select correctly, and get no "blank page" errors as a typo would give. Instead, I'm just getting an empty array. No results returned, but I believe there to be.

$db = JFactory::getDbo();

$query = $db->getQuery(true);

$query->select($db->quoteName(array('id', 'video_title')));
$query->from($db->quoteName('#__films_videos'));

$db->setQuery($query);
$results = $db->loadObjectList();

if($results) {
    print_r($results);
}else{
    echo '<pre>Oops! No results  :(</pre>';
}

I'm rather new to Joomla, but I understand databases pretty well after 14 years of custom web development & Wordpress experience. Just not sure where I'm tripping up. Any ideas? I keep triggering the else.

films_videos is indeed the name of our module, and no Joomla errors present themselves in the output of a page load.

  • As I can see the query is correct. Are you sure that #__films_videos contains any data? – Dmitry Rekun Nov 21 '14 at 8:27
  • query seems correct to me. check whether there are any records in the table(films_videos) or not. Make sure you are connecting to correct database. – Nick Nov 21 '14 at 8:40
  • 1
    If it were me, i'd add echo $query->dump();die; right before executing it and see what the SQL actually is, then run that myself in MySQL to see syntax/results/errors....a little brute force, but might do the trick – GDP Nov 21 '14 at 14:39
  • (this page seems safe to delete from the site, I don't have delete-vote privileges on this site) – mickmackusa Apr 6 '18 at 1:40
1

Long story short, the client had several components similarly named and I wasn't aware that was happening. I was calling against the wrong database.

Thank you for the answer, and everybody was correct. I knew somehow something was "off"!

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.