Problem with _cm_filterwhere, how can do this? [message #1694] |
Mon, 22 September 2008 12:35  |
bonzo_bcn
Messages: 152 Registered: June 2008
|
Senior Member |
|
|
In _cm_intialise I modify the $where clause as follows:
$where = "(".$where.") AND participante_id IN (SELECT participante_id FROM part_ent_xref WHERE entidad_id=" .$entidad_id[0]['entidad_id'] . ")";
I found that filterWhere removes the parentheses in
How can I do it so the parentheses aren't removed?
|
|
|
Re: Problem with _cm_filterwhere, how can do this? [message #1695 is a reply to message #1694] |
Mon, 22 September 2008 18:46   |
AJM
Messages: 2379 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
You cannot. The $where string is assumed to have been constructed from the primary keys of one or more table rows and may not accept some complex modifications as they may fall foul of the filtering process. This has to unpack the string into an array, examine each part for possible action (such as prefixing a field name with a table name, or removing the field altogether), then convert the array back into a string. During this process it is possible for extraneous parentheses to be removed.
Additional selection criteria may be added by using either $this->sql_where or $this->search.
In the example you give where you are including an additional conditon with an 'AND' I cannot see that the parentheses would make any difference.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
Re: Problem with _cm_filterwhere, how can do this? [message #1697 is a reply to message #1696] |
Tue, 23 September 2008 04:26   |
AJM
Messages: 2379 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
If you are deleting records from the 'part_ent_xref' table then it is the 'part_ent_xref' object that should be the subject of the DELETE task. This means that the $where clause which is passed to the DELETE task will contain the primary key of each selected entry in the format:
field1='value1' AND field2='value2'
If there are multiple selections each primary key will be enclosed in parentheses and separated by ' OR ', as in:
(field1='v1' AND field2='v2') OR (...) OR (...)
I have similar tables (PERSON and PERS_OPT_XREF) in the XAMPLE prototype which is included in the Radicore download, and I do not have an problem in deleting selected entries.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
|
Re: Problem with _cm_filterwhere, how can do this? [message #1700 is a reply to message #1699] |
Tue, 23 September 2008 05:58  |
AJM
Messages: 2379 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
Anything is possible if you think about it.
The fact that the xref table is transparent to the user is irrelevant. If you want to delete entries from the xref table then the DELETE task *must* use the xref table object. If you wish the screen to contain details from the person record then it is a simple matter to have the xref object perform a JOIN to the person table so that the necessary details can be included in the output. The user need not know that the person data was obtained indirectly via a JOIN and not directly, just that the person data is being displayed.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|