Hi I would be very grateful if someone could help me out.
I have been having trouble getting a connection to 2 tables using a left join inside Chronoforms 6, so I modelled it up in PHP in a custom html module in Joomla, and the following code works. But I would like to be working in Chronoforms, so I put it in a PHP object in Setup.
I get the following error however: Call to a member function select() on null
Would somebody please let me know how I can adapt the database connection to work in Chronoforms?
[pre]$db = JFactory::getDbo();
$query = $db->getQuery(true);
[br]$query -> select ('assets.asset_id, assets.type_of_resource, bookings.start_date, bookings.request_delivery');[br]$query -> from('#__tblAssets AS assets');[br]$query ->leftjoin('#__tblBookings AS bookings ON assets.asset_id = bookings.asset_id');[br][br]$db->setQuery($query);[br]//loadObjectList to get all results in the array;[br]$results=$db->loadObjectList();[br][br]echo'<tr><td>';[br]echo $d->asset_id .'</td>';[br]echo '<td>'. $d->start_date .'</td>';[br]echo '<td>'. $d->end_date .'</td>';[br]echo '<td>'. $d->type_of_resource .'</td>';[br]echo '<td>'. $d->request_delivery .'</td>';[br][br]echo'</tr>';[br][br]foreach($results as $d){[br][br]echo'<tr><td>';[br]echo $d->asset_id .'</td>';[br]echo '<td>'. $d->start_date .'</td>';[br]echo '<td>'. $d->end_date .'</td>';[br]echo '<td>'. $d->type_of_resource .'</td>';[br]echo '<td>'. $d->request_delivery .'</td>';[br][br]echo '</tr>';[br]}[br][/pre][br]echo '</table>';[br][br]
I have been having trouble getting a connection to 2 tables using a left join inside Chronoforms 6, so I modelled it up in PHP in a custom html module in Joomla, and the following code works. But I would like to be working in Chronoforms, so I put it in a PHP object in Setup.
I get the following error however: Call to a member function select() on null
Would somebody please let me know how I can adapt the database connection to work in Chronoforms?
[pre]$db = JFactory::getDbo();
$query = $db->getQuery(true);
[br]$query -> select ('assets.asset_id, assets.type_of_resource, bookings.start_date, bookings.request_delivery');[br]$query -> from('#__tblAssets AS assets');[br]$query ->leftjoin('#__tblBookings AS bookings ON assets.asset_id = bookings.asset_id');[br][br]$db->setQuery($query);[br]//loadObjectList to get all results in the array;[br]$results=$db->loadObjectList();[br][br]echo'<tr><td>';[br]echo $d->asset_id .'</td>';[br]echo '<td>'. $d->start_date .'</td>';[br]echo '<td>'. $d->end_date .'</td>';[br]echo '<td>'. $d->type_of_resource .'</td>';[br]echo '<td>'. $d->request_delivery .'</td>';[br][br]echo'</tr>';[br][br]foreach($results as $d){[br][br]echo'<tr><td>';[br]echo $d->asset_id .'</td>';[br]echo '<td>'. $d->start_date .'</td>';[br]echo '<td>'. $d->end_date .'</td>';[br]echo '<td>'. $d->type_of_resource .'</td>';[br]echo '<td>'. $d->request_delivery .'</td>';[br][br]echo '</tr>';[br]}[br][/pre][br]echo '</table>';[br][br]