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

Home » RADICORE development » Bug Reports » getInitialDataMultiple does not deal with ') OR (' in $where parameter
getInitialDataMultiple does not deal with ') OR (' in $where parameter [message #1139] Wed, 24 October 2007 19:22 Go to next message
alrobertson is currently offline  alrobertson
Messages: 9
Registered: October 2007
Location: Vancouver
Junior Member
I have a LIST2 screen which has a nav button to call ADD4 on another table with the multiple selections from the LIST2 screen.
I then wanted to look up the selected records and use some of that data to make the new records.

if 2 lines are selected on the LIST2 screen, ADD4 gets $where = "( primaryfieldname='X' ) OR ( primaryfieldname='Y' )".
When where2array parses it in getInitialDataMultiple() it messes up.

I realize I can do something in _cm_initialize to grab it first but it would sure be nice if passing the above $where to where2array($where) would create:
array( primaryfieldname => array(X,Y) )

and then calling array2where() would put it to:
"primaryfieldname IN ('X','Y')"

if not, it would at least be good if some form of an array got through to _cm_getInitialDataMultiple($fieldarray).

Let me know if I am missing some other obvious solution. I am using 1.28.0

Thanks
Re: getInitialDataMultiple does not deal with ') OR (' in $where parameter [message #1140 is a reply to message #1139] Thu, 25 October 2007 05:40 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
I've had a play with this and changed the getInitialDataMultiple() method so that it outputs a multi-dimensional array (indexed by row number, then associative for each row) instead of an associatve array for a single row only. This will be released in version 1.30.0 which will be available shortly.

In the meantime you can try this code - in the getInitialDataMultiple() method of std.table.class.inc change this:
        if (!empty($where)) {
            if (is_array($where)) {
                $fieldarray = $where;
            } else {
                // convert 'where' string to an associative array
                $fieldarray = where2array($where);
            } // if
        } else {
            $fieldarray = array();
        } // if
to this:
        if (!empty($where)) {
            if (is_array($where)) {
                $fieldarray = $where;
            } else {
                // convert 'where' string to an array which is indexed by row number
                $array1 = splitWhereByRow($where);
                // convert 'where' for each row into an associative array
                foreach ($array1 as $rownum => $rowdata) {
                    $fieldarray[] = where2array($rowdata);
                } // foreach
            } // if
        } else {
            $fieldarray = array();
        } // if

Let me know if this solves your problem.


Re: getInitialDataMultiple does not deal with ') OR (' in $where parameter [message #1141 is a reply to message #1139] Thu, 25 October 2007 12:52 Go to previous messageGo to next message
alrobertson is currently offline  alrobertson
Messages: 9
Registered: October 2007
Location: Vancouver
Junior Member
That works perfect!

Thanks
Re: getInitialDataMultiple does not deal with ') OR (' in $where parameter [message #1154 is a reply to message #1140] Tue, 30 October 2007 16:53 Go to previous messageGo to next message
alrobertson is currently offline  alrobertson
Messages: 9
Registered: October 2007
Location: Vancouver
Junior Member
The fix worked for my purposes but it broke "dict_table_s01" since it does not expect the array. I suppose any call to a _cm_getInitialDataMultiple() that does not expect the array will be broken.
Re: getInitialDataMultiple does not deal with ') OR (' in $where parameter [message #1155 is a reply to message #1154] Tue, 30 October 2007 20:27 Go to previous message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
The attached files should fix the problem.

Previous Topic: using Popup on outer table of MULTI4
Next Topic: calling ADD2 from LIST1 with $where set.
Goto Forum:
  


Current Time: Thu Nov 28 23:22:48 EST 2024

Total time taken to generate the page: 0.01122 seconds