Returning ids via php

jh

Member
Hi

I wanted to return selected ids from another table to use as values in a URL 'IN' condition filter in the details view of another table - so the values returned are eg (5,11,16), which is then used as a placeholder for the url filter. I hope that makes sense.

I can get the id values in testing using a calc but as these values are not stored in the db I believe I have to do them via php - only I can not seem to get these values to be returned. I have tried using a php on form load plugin but ca not get any values to be returned.

If someone could kindly instruct me how to return these values I would be very grateful.

Kind Regards
 
No one can tell you why your result from database is empty.
  • write down the code you use,
  • the form plugin settings,
  • test to see if the sql query returns the result you want to do,
  • ... ;
Do not spare the descriptions when you want someone to cooperate.
 
Hi

Thank you, you are quite right.

To get the results using calc, I have used:
...........................
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$myQuery->select ('designer_db_upgrade')->from('pat_tab')->where('chose = "{fac_table___id}"');
$myDb->setQuery($myQuery);
$results = $myDb->loadObjectList();
$html = '';
foreach ($results as $result) {
$html .= "" . $result->designer_db_upgrade . ",";

}
return $html;

.........................

This returns the results like (1,7,) which I believe would work as a placeholder for my URL filter.

However as this value was just got from using a calc, I want to set these values via PHP.

I have tried using a PHP events plug in on a list, set to run on pre-load data. I have tried to adapt my code to:

$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$myQuery->update('factory_table as d')
->set('d.des_num = (SELECT p.designer_db_upgrade FROM pat_tab as p WHERE p.chose = d.id)');
$myDb->setQuery($myQuery);
$results = $myDb->loadObjectList();
$html = '';
foreach ($results as $result) {
$html .= "" . $result->designer_db_upgrade . ",";

}
return $html;

however it returns an error : 1242 Subquery returns more than 1 row

I am not sure where I am going wrong, so any help would be gratefully received.

Kind Regards
 
In first code you have select query.
In second block of code you have update query.
Try to think what you want to do and learn step by step which part of code what do.
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top