Quantcast
Channel: Joomla! Forum - community, help and support
Viewing all articles
Browse latest Browse all 2110

Joomla! 5.x Coding • Query returning 0 rows, when there is a row

$
0
0
Ok. Stumped on this one. I am querying a custom table in Joomla 5.1.0. It is returning 0 rows. No errors. However, there is a row in the database. Code is below. When I run the query manually in phpMyAdmin, it returns the 1 row.
phpMyAdmin query.
SELECT `payment_tracking_num` FROM `jos7x_payment_tracking` WHERE `groupID` = 55;
returns:
payment_tracking_num
Edit Copy Delete 21212221

Code:

use Joomla\CMS\Factory;use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;// Get a db connection.$db = JFactory::getDbo();// used for testing.  $group_id = 55;// Create a new query object.$Qgroup = $db->getQuery(true);$Qgroup->select($db->quoteName('payment_tracking_num'));$Qgroup->from($db->quoteName('#__payment_tracking'));$Qgroup->where($db->quoteName('groupID') . ' = ' . (int) $group_id);// Reset the query using our newly populated query object.$db->setQuery($Qgroup);// Load the results as a list of stdClass objects (see later for more options on retrieving data).$results = $db->loadObjectList();$rowcount = $db->getNumRows();echo $Qgroup . '<BR>' . $Qgroup->dump . '<BR>' . $results['payment_tracking_num'] . '<BR>' . $rowcount;
Image

Statistics: Posted by cscotthosting — Mon May 20, 2024 11:34 am



Viewing all articles
Browse latest Browse all 2110

Trending Articles