setQuery($query);$Request =& $db2->loadObjectList();i am not getting any results from the connection.I have been usingecho $Request->request_id ;to try and see what resultsare returned, but i get nothing.What i want to do is use the returned row to build my query in the WHERE box of the CC listing main table.advertised_price The debugger shows no data. i am aware that it shouldn't as the connection to the table isn't working properly.Where am i going wrong? and is it even possible to do what i want.I could build this with CF, but want to use the built in filtering of CCKind RegardsAllan"> Connect to a table that is unrelated to main table - Forums

Forums

Connect to a table that is unrelated to main table

allanbeth 16 Dec, 2013
Hi all,

I want to connect to a table that has no relationship to the main table in my CC.

I want to use this table to build the WHERE query in my CC listing.

It's basically a multi field search listing.

I am passing the id of the row from the unrelated table using the URL pass method.
$param = JRequest::getInt('request_id', '', 'get');


That works fine, and get the correct entry being passed.

I'm then using the $param variable to query the connection
$db2 =& JFactory::getDBO();

$query = "
    SELECT *
        FROM `hma_requests` 
        WHERE `request_id` = $param;
";
$db2->setQuery($query);
$Request =& $db2->loadObjectList();


i am not getting any results from the connection.

I have been using
echo $Request->request_id ;
to try and see what resultsare returned, but i get nothing.

What i want to do is use the returned row to build my query in the WHERE box of the CC listing main table.
advertised_price <= <?php echo "'{$Request['budget']}'" ; ?>


The debugger shows no data. i am aware that it shouldn't as the connection to the table isn't working properly.

Where am i going wrong? and is it even possible to do what i want.

I could build this with CF, but want to use the built in filtering of CC

Kind Regards

Allan
allanbeth 17 Dec, 2013
Follow up Info.

I used the following code to see if anything was outputted from the connection
print_r2($Request);


This pulls out the correct record from the table using the passed parameter from the page URL.


i have tried to echo the data in one of the fields, the correct value is returned when using the following

echo $Request[0]['budget'] ;


The problem now is that it wont work when i use it to build the WHERE statement.
Could this be a scope issue?

Can some one point me in the right direction as to how i get the data into the WHERE.

im using
advertised_price <= '<?php echo $Request[0]['budget'] ;?>'


Hope that makes sense?

Kind Regards

Allan
Max_admin 17 Dec, 2013
Hi Allan,

Please enable the connection's debug, can you see the correct where used in the query ?

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
allanbeth 17 Dec, 2013
Hi Max,

I have the debug enabled.

I'm pretty sure that it is a scope issue that i'm not grasping correctly.

If i put the connection code into the WHERE box it all works fine and i can get it to do exactly what i want it to do, however as soon as i use any of the filters that i have set (to change the ORDER using the List View Fields) the passed parameter that i am using to get the data to build the query is lost.

Any advice?

Allan
Max_admin 20 Dec, 2013
Hi Allan,

If you are using the "Custom listing" then you can insert a hidden field into the header or footer and publish its value with the parameter value, or in case of auto listing, you can store it in session in the where box itself, simply check if its empty in the request or not, if empty then load from session, if not empty then use it and store it in session!

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
This topic is locked and no more replies can be posted.