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

Home » RADICORE » How To » Problem with _cm_filterwhere, how can do this?
Problem with _cm_filterwhere, how can do this? [message #1694] Mon, 22 September 2008 12:35 Go to next message
bonzo_bcn is currently offline  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
"(".$where.")


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 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
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.


Re: Problem with _cm_filterwhere, how can do this? [message #1696 is a reply to message #1694] Tue, 23 September 2008 02:31 Go to previous messageGo to next message
bonzo_bcn is currently offline  bonzo_bcn
Messages: 152
Registered: June 2008
Senior Member
In fact it does make a difference only in one screen: when the user selects more than one record for deletion:

I have a table persons and then a table part_ent_xref that links the person to the users 'entidad_id' ($entidad_id[0]['entidad_id']).

The where clause is modified so the user can only see the persons that are linked to him.

When the user selects several persons for deletion and presses the submit button, I'm not deleting the record from persons but from part_ent_xref, so if for example the original $where is:

participante_id=1 OR participante_id=4 OR participante_id=6 AND participante_id IN (SELECT participante_id FROM part_ent_xref WHERE entidad_id=7)

If I select the three persons and click on delete, and delete the record in part_ent_xref where participante_id=1, on the del1 screen the person with participante_id=1 still shows up.

I tried the where clause with parenthesis and then it doesn't show up.

(If I didn't explain myself I can give you the login details so you can check yourself)
Re: Problem with _cm_filterwhere, how can do this? [message #1697 is a reply to message #1696] Tue, 23 September 2008 04:26 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
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.


Re: Problem with _cm_filterwhere, how can do this? [message #1698 is a reply to message #1694] Tue, 23 September 2008 04:38 Go to previous messageGo to next message
bonzo_bcn is currently offline  bonzo_bcn
Messages: 152
Registered: June 2008
Senior Member
You're right, I'll try that approach.
Thanks!
Re: Problem with _cm_filterwhere, how can do this? [message #1699 is a reply to message #1694] Tue, 23 September 2008 05:37 Go to previous messageGo to next message
bonzo_bcn is currently offline  bonzo_bcn
Messages: 152
Registered: June 2008
Senior Member
Ok, I looked at your example and it's not quite the same of what I need.

My xref table is transparent to the user, he doesn't know it exists. When any user creates a person I insert a record in the xref table so I know the person belongs to that user. When the user deletes the person I want to keep the record in the ddbb and I just erase the link in the xref table.

If there is no record in the xref table the user won't see that record (that's when the where clause comes to play).

All transparent to the user.

So ideally I would like that when the user selects several persons and clicks 'delete' a xref del1 transaction will appear (showing the person data), but I think that it is not possible to do this.
Re: Problem with _cm_filterwhere, how can do this? [message #1700 is a reply to message #1699] Tue, 23 September 2008 05:58 Go to previous message
AJM is currently offline  AJM
Messages: 2347
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.


Previous Topic: Force a PDF page break
Next Topic: _cm_listview_total() problem
Goto Forum:
  


Current Time: Thu Mar 28 15:09:10 EDT 2024

Total time taken to generate the page: 0.01030 seconds