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

Home » RADICORE » How To » Update 4
Re: Update 4 [message #945 is a reply to message #944] Wed, 11 July 2007 13:46 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
I have just tried multiple selections with my MULTI4, and the selection string which is created contains those multiple selections. You must have something wrong in your code.

Step through with your debugger, particulary at lines 180 and 181 in the childform() function in file 'include.session.inc' as this is where the contents of $fieldarray is turned into a string based on which rows were selected.


Re: Update 4 [message #946 is a reply to message #945] Wed, 11 July 2007 14:48 Go to previous messageGo to next message
danpoleary is currently offline  danpoleary
Messages: 49
Registered: February 2007
Member
Yes, I had confirmed that before, and just now, and all records selected exist in the debugger at that location, but when it enters update4, only the first record exists. I checked inside the _cm_pre_getData of the class used in update4.

dan
Re: Update 4 [message #947 is a reply to message #946] Wed, 11 July 2007 15:23 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
You need to step through every part of the UPDATE4 to see where the $where string is being modified as it passes through several methods before it gets to _cm_pre_getData().

Re: Update 4 [message #948 is a reply to message #947] Thu, 12 July 2007 08:44 Go to previous messageGo to next message
danpoleary is currently offline  danpoleary
Messages: 49
Registered: February 2007
Member
Good morning Tony,

I think I found it, but a I am not sure why it is this way.

when the call is made to my _cm_pre_getData, the $where contains all the selections, but the $where_array only contains the first record. In your sample above, you stripped the sel_publish_key from the $where_array. Should this have been stripped from the $where instead? or, does a problem exists in whic the $where_array is not populated correctly?

Thanks,

Dan

Re: Update 4 [message #949 is a reply to message #948] Thu, 12 July 2007 09:28 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
That is by design, actually. The $where_array in _cm_pre_getData() only shows values from the first selected row so that it is easy to determine which field names have been specified, and there is no need to duplicate the same field name for every row as they are all the same (just with different values).

In your case it would be better to extract the value for 'sel_publish_key' in the _cm_initialise() method as it will be filtered out of the $where string in the code which follows (provided that 'sel_publish_key' has not been manually inserted into the $fieldspec array). You can do it with code such as:
function _cm_initialise ($where)
{
    $where_array = where2array($where);
    $this->sel_publish_key = $where_array['sel_publish_key'];

    return $where;

} // _cm_initialise


Re: Update 4 [message #950 is a reply to message #949] Thu, 12 July 2007 10:13 Go to previous messageGo to next message
danpoleary is currently offline  danpoleary
Messages: 49
Registered: February 2007
Member
Hmmm,

I changed the code, but now something strange happens. When the call is made to _cm_initialise, the where does does contain everything, but the call to where2array, only returns the first occurrence, also, the where still contains the sel_publish_key in subsequent methods.

Dan
Re: Update 4 [message #951 is a reply to message #950] Thu, 12 July 2007 10:50 Go to previous messageGo to next message
danpoleary is currently offline  danpoleary
Messages: 49
Registered: February 2007
Member
Just as an update, I validated the fieldspec array inside the update4 methods, and it does not contain the sel_publish_key field.

Dan
Re: Update 4 [message #952 is a reply to message #950] Thu, 12 July 2007 10:51 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
Surely you only need the first occurrence as the value for 'sel_publish_key' is the same for every occurrence? There is only a single value available on the previous MULTI4 function.

The reason that 'sel_publish_key' is not being filtered out of the $where string is that it is contained within the $fieldspec array, presumably because of code within the _cm_changeConfig() method. This addition is necessary in the MULTI4 function, but not in the UPDATE4 function.


Re: Update 4 [message #953 is a reply to message #952] Thu, 12 July 2007 10:59 Go to previous messageGo to next message
danpoleary is currently offline  danpoleary
Messages: 49
Registered: February 2007
Member
As per my note above, I have validated that the update4 use of the filelist class does not modify the fieldspec array, by adding a check against getSelf() to ensure that the addition of sel_publish_key is only applied if the call current script is "filelist(multi4).php'.

That is why I am confused a bit, since the where still contains this field.

Dan
Re: Update 4 [message #954 is a reply to message #953] Thu, 12 July 2007 11:06 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
The $where string will not be filtered to remove 'sel_publish_key' until AFTER the call to _cm_initialise(). Take a look inside the initalise() method at the filterWhere() function.

Re: Update 4 [message #955 is a reply to message #954] Thu, 12 July 2007 11:34 Go to previous messageGo to next message
danpoleary is currently offline  danpoleary
Messages: 49
Registered: February 2007
Member
The following condition passes even though it should not when $fieldname contains sel_publish_key:

if (ereg('\b', $fieldname) OR array_key_exists($fieldname, $fieldlist) AND !isset($fieldlist[$fieldname]['nondb'])) {

fieldlist does not contain sel_publish_key.

Why would it pass this condition?
Re: Update 4 [message #956 is a reply to message #955] Thu, 12 July 2007 11:53 Go to previous messageGo to next message
danpoleary is currently offline  danpoleary
Messages: 49
Registered: February 2007
Member
I think I found the problem, the '\b' against ereg, looks for beginning or end of word, and will always evaluate to true. Was this your intent? or were you looking for digits instead?

Dan
Re: Update 4 [message #957 is a reply to message #956] Thu, 12 July 2007 14:59 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
If you look at the comment before that line you will see that I am looking for multiple words, and '\b' is supposed to test for a word boundary. It returns false with a fieldname of 'foobar' but true if it contains '_' (underscore) as in 'sel_publish_key'. If you change
ereg('\b', $fieldname)
to
preg_match('/\w+ \w+/', $fieldname)
you should find that it solves the problem.


Re: Update 4 [message #958 is a reply to message #957] Fri, 13 July 2007 11:37 Go to previous messageGo to next message
danpoleary is currently offline  danpoleary
Messages: 49
Registered: February 2007
Member
Thanks,

Everything works great now. I can select records and it applies the update to them. One thing I have noticed however, is that if I do not select anything in the inner entity on the multi4 screen, but still select the auto_publish button (update4), it will update all the records in the inner entity by setting the autopublish boolean to true, but ignore the outer selected sel_publish_key.

Why would it update records if none have been selected? and if this is normal, how can I validate that the records have been selected inside the method auto_publish or its extended class?

I am stepping through everything, but any pointers on where to aim my search would be greatly appreciated.

Thanks for all your help
dan

Re: Update 4 [message #959 is a reply to message #958] Fri, 13 July 2007 12:11 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
When you press a navigation button without selecting any entries the framework will create a selection string using the $where cause which went into the database object. In this case it will be the inner entity of the MULTI4. Because this selection string is not empty it will not be rejected by the UPDATE4 controller, so you will need code in your database object to inspect the $where string for validity before being allowed to continue.

The best place to do this would be the _cm_initialise method. If the $where string is invalid simply put an error message into $this->errors[] and the UPDATE4 controller will terminate and return to the MULTI4.


Re: Update 4 [message #960 is a reply to message #959] Fri, 13 July 2007 13:47 Go to previous message
danpoleary is currently offline  danpoleary
Messages: 49
Registered: February 2007
Member
Thanks,

Everything work excellent.

Thanks for all your help,

Dan
Previous Topic: javascript not working
Next Topic: Accessing Radicore for the first time
Goto Forum:
  


Current Time: Thu Nov 28 22:27:38 EST 2024

Total time taken to generate the page: 0.01475 seconds