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

Home » RADICORE development » Bug Reports » updateSelection cannot extract token (updateSelection with multiple SET result in Fatal Error)
updateSelection cannot extract token [message #2916] Sat, 17 March 2012 02:05 Go to next message
kong is currently offline  kong
Messages: 90
Registered: December 2011
Member
Radicore v1.72.0
Apache Version 2.2.21
PHP Version 5.3.8
MySQL Version 5.5.16

1. Use updateSelection with multiple SET like this:

function _cm_post_updateRecord ($rowdata, $old_data)
{
$a = 1;
$b = 2;
$where = "'{$rowdata['lft']}'<lft AND rgt<'{$rowdata['rgt']}'";
$replace = "lvl='lvl+{$a}', lft='lft+{$b}', rgt='rgt+{$b}'";
this->updateSelection($where, $replace);
return $rowdata;
} // _cm_post_updateRecord

2. Doing the above will result in:

Fatal Error: Cannot extract token from: ', lft='lft+2', rgt='rgt+2'' (# 256).

3. Had to rewrite into something like below in order to avoid this fatal error:

function _cm_post_updateRecord ($rowdata, $old_data)
{
$a = 1;
$b = 2;
$where = "'{$rowdata['lft']}'<lft AND rgt<'{$rowdata['rgt']}'";
$replace = "lvl='lvl+{$a}'";
this->updateSelection($where, $replace);
$replace = "lft='lft+{$b}'";
this->updateSelection($where, $replace);
$replace = "rgt='rgt+{$b}'";
this->updateSelection($where, $replace);
return $rowdata;
} // _cm_post_updateRecord

Re: updateSelection cannot extract token [message #2919 is a reply to message #2916] Sat, 17 March 2012 05:54 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2368
Registered: April 2006
Location: Surrey, UK
Senior Member
Firstly, if you wish to increment a numeric column you must use "lvl=lvl+1" and not "lvl='lvl+1'". If you enclose the update value in quotes it will be treated as a string.

Secondly, I have made some slight code changes in the attached zip file which should help.


Re: updateSelection cannot extract token [message #2921 is a reply to message #2919] Sat, 17 March 2012 22:56 Go to previous messageGo to next message
kong is currently offline  kong
Messages: 90
Registered: December 2011
Member
Thanks, I will try.
Re: updateSelection cannot extract token [message #2923 is a reply to message #2921] Sun, 18 March 2012 05:25 Go to previous messageGo to next message
kong is currently offline  kong
Messages: 90
Registered: December 2011
Member
Your patch fixed the problem. Thanks.
Re: updateSelection cannot extract token [message #2924 is a reply to message #2923] Sun, 18 March 2012 05:40 Go to previous message
AJM is currently offline  AJM
Messages: 2368
Registered: April 2006
Location: Surrey, UK
Senior Member
I knew I'd get it right eventually Smile

Previous Topic: auto_increment
Next Topic: Re-enabling user loses rdcaccount
Goto Forum:
  


Current Time: Sun Nov 24 21:05:36 EST 2024

Total time taken to generate the page: 0.03275 seconds