Forums

Joomla 3.1 Query DB

esl 23 May, 2013
I have this form that would pull in info from the database with no problem on a j1.5 site... I have since upgraded the site to j3.1 and now i can pull in the info at all....

here is the code im using, what would i need to do to echo the results?

<?php
$user =& JFactory::getUser();
$userid=$user->id;

$db = JFactory::getDbo();

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

$query->select(array('cf_user_id'));
$query->from('#__formintake_2');
$query->where('cf_user_id = '. $user->id);


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

?>


I get an array of the objects in this format

stdClass Object ( [cf_user_id] => 578 ) [1] => stdClass Object ( [cf_user_id] => 578 ) [2]
GreyHead 24 May, 2013
Hi esl,

What exactly do you need to do with the results? In this query it looks as though you are getting the value of cf_user_id which you already know?

ChronoForms has a DB Record Loader action that will do most of this for you.

If you need to add a custom query then I'd add the results to the $form->data array so that ChronoForms knows about them. using loadAssocList() may also be more helpful as it gives an array of arrays.

Bob
This topic is locked and no more replies can be posted.