Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Thursday, December 3, 2026
About Us
Magazine
Open Source
CVS
Services
Index  »  Projects  »  phpMyEdit  »  Forum  »  Query data into dummy field

phpMyEdit General     Query data into dummy field
Post new topic   Reply to topic    
 
Mike51     Joined: 06 Jan 2007   Posts: 3  
Post Posted: 2007-01-06 12:23
Back to top  Reply with quote     

I have a data model with 2 tables:
- ADDRESSES
- PERSONS
Several persons can live at one address.
In the ADDRESSES form, I want to include a dummy field which lists the PERSONS for that address. So it would look like:

Code:

LOCATION      NAMES
------------  ---------------
Whitehouse    George, Barbara
Downingstraat Tony, Cherie

So the SQL for this dummy field would be something like:
SELECT name FROM persons WHERE address_id = $this->rec

Is this at all possible? I can see that I probably need some PHP to concatenate the names of the rows returned but I can't find an appropriate starting point in the manual.
Any help is appreciated.

 
michal     Joined: 17 Jun 2003   Posts: 537   Location: Slovakia
Post Posted: 2007-01-08 17:16
Back to top  Reply with quote     

basically there are two possiblities:
- sql option (if your version of mysql is high enough, if mysql has comma separate aggregate function). it would be:
'sql'=> "SELECT comma(name) FROM persons WHERE address_id = PMEtable0.id group by address_id";

-php option (from cvs version) lets you do this easier. just create a file that will return the names and include it with php option (see cvs docs).

 
Mike51     Joined: 06 Jan 2007   Posts: 3  
Post Posted: 2007-01-08 19:50
Back to top  Reply with quote     

Michal, thanks for your answer.
I will need to go with the PHP option. I have been able to return a static value from PHP (using pme 5.6), but I need to acccess the primary key value of the record in the PHP procedure.
How do I do this?
By the way, in what way has the CVS version improved on 5.6 in this area?
Thanks,
Mike

 
michal     Joined: 17 Jun 2003   Posts: 537   Location: Slovakia
Post Posted: 2007-01-23 13:38
Back to top  Reply with quote     

yes, it's improved

use 'sql=>'id' (or the key value)
'php'=>'sum.php'

in sum.php use $value

 
Mike51     Joined: 06 Jan 2007   Posts: 3  
Post Posted: 2007-01-25 22:12
Back to top  Reply with quote     

Thanks. It works! My php file looks like this:
Code:

  $namelist = '';
  $res = $this->myQuery('select * from persons where address_id=' . $value);
  while ($row = @mysql_fetch_assoc($res)) {
    if (!empty($namelist)) {
      $namelist .= ', ';
    }
    $namelist .= $row['name'];
  }
  return $namelist;


 
Post new topic   Reply to topic    

Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top · Feedback form · Application form
Report bug on PLATON.SK website · Terms of use · Privacy policy