Accessing database

jh

Member
Hi

I wanted to try and create a custom module which containted some text and data from my fabrik databases. I have tried to do this with Sourcerer but I can not seem to get it to return anything. I have tried code along the lines of:

{source}<?php
$query = $db->getQuery(true)
->select($db->quoteName('factory'))
->from('object_table')
->where($db->quoteName('id').' = '.$db->quote('3'));

$db->setQuery($query);
$result = $database->loadResult();

return $result;
?>{/source}

but nothing is being returned.

Have I missed something or is it not possible to return data this way?

Many thanks
 
PHP:
{source}<?php
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('factory'))
->from('object_table')
->where($db->quoteName('id').' = '.$db->quote('3'));

$db->setQuery($query);
$result = $database->loadResult();

return $result;
?>{/source}
 
Why 'return'?

If that code is in a custom module, there's nothing to return to. You need to echo the response, not return it. When J! runs custom modules, it captures the output buffer.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Staff online

Members online

Back
Top