Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE development » Transaction Patterns » Dropdown list (Selecting occurences)
Dropdown list [message #4473] Mon, 18 August 2014 09:21 Go to next message
htManager is currently offline  htManager
Messages: 316
Registered: May 2014
Senior Member
I have a dropdown list in which I want to list entries from a database table. Now I don't know how to change or create the selection criteria.

Can I change the $where criteria in the _cm_getValRep method of the class? If yes, how can I do this?

The first fields of the primary key are the same for both tables. So how can I get these values for using in the selection criteria?

Here is the code:

function _cm_getValRep ($item=null, $where=null)
// get Value/Representation list as an associative array.
{
$array = array();

if ($item == 'ma_mitglieder') {
// get data from the database
$where = $where_mannschaft;
$this->sql_select = 'kontakt_ma_user_id, kontakt_ma_user_seq_no, kontakt_ma_name, kontakt_ma_vorname';
$this->sql_orderby = 'kontakt_ma_name';
$this->sql_ordery_seq = 'asc';
$data = $this->getData($where);

// convert each row into 'id=desc' in the output array
foreach ($data as $row => $rowdata) {
$rowvalues = array_values($rowdata);
$array[$rowvalues[0]] = $rowvalues[0];
} // foreach

return $array;
} // if

return $array;

} // _cm_getValRep
Re: Dropdown list [message #4474 is a reply to message #4473] Mon, 18 August 2014 11:55 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2244
Registered: April 2006
Location: Surrey, UK
Senior Member
If you look very carelfully at the getValRep() and _cm_getValRep() methods inside std.table.class.inc you will see that they both have optional arguments for $where and $orderby. Inside the _cm_getValRep() method you will see the following line of code:
$data = $this->getData($where);

This means that all you have to do is supply a value for $where when you call the getValRep() method.


Re: Dropdown list [message #4482 is a reply to message #4474] Tue, 19 August 2014 05:48 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 316
Registered: May 2014
Senior Member
Thank you, I see it.
I tried this before I posted but I didn't succeed. Now that I know that this is the right way I get the desired data if I initialize the $where string manually.
So how do I get the pk information from the calling table (object/form)?
Is it a good idea to use the $Global variable? Or is there a better way?
Re: Dropdown list [message #4483 is a reply to message #4482] Tue, 19 August 2014 06:31 Go to previous message
AJM is currently offline  AJM
Messages: 2244
Registered: April 2006
Location: Surrey, UK
Senior Member
You only need to provide a $where string if you want a subset of the records from the ValRep table. By default it will select all records. If you want a subset then it is up to you to provide the $where string manually. The framework cannot do that for you as it does not know what subset you want.

Previous Topic: Calculated fields
Next Topic: Error running output2 pattern
Goto Forum:
  


Current Time: Wed May 12 15:42:39 EDT 2021

Total time taken to generate the page: 0.01477 seconds