This topic is locked

Handling of Unsigned BigInts

9/14/2006 10:55:07 AM
PHPRunner General questions
V
vivek author

Hi there,
Is it possible that when I use unsigned bigints the last character gets lost when doing lookups in MySQL database form phpRunner generated scripts. I use ID's like the following 10210000001000002 and somehow the last digit sometimes gets especially when referencing records in for instance master detail relationships. Anyone have any experience with this ?

Admin 9/19/2006

Hi,
as far as we know PHP maps BIGINT fields to simple integers or to double, so PHPRunner doesn't fully support BIGINT fields.

I can recommend you to change your ID type to VARCHAR because BIGINT is not a widely supported MySQL type.

V
vivek author 10/3/2006

I tried reproducing the problem in my own handwritten code but wasn't able to.

I have no problem with inserting, selecting or deleting bigints. Changing to a string is not an option since these fiels are autoincrement fields.
There should be a workarround to this in phpRunner. I tried setting up a fresh project in 3.1 (which is a great improvement by the way) but it had the same results.
Where can I change the generated code so that bigints are mapped to strings ?

Admin 10/5/2006

Hi,
PHPRunner converts BIGINT values to integers.

This is needed to remove all the non-numeric characters from user input to fix input errors and protect the pages from SQL injection attacks.
Here is the construct we use:

$var1 = 0+$var2;



To get your BIGINT fields working properly you can replace it with the following code:

$var2=substr($var2,0,strspn($var2,"01234567890.-"));

if(!strlen($var2))

$var2="0";

$var1=$var2;



This will keep your pages protected from SQL injection attacks however won't fix user input errors.

You need to do 3 replacements in include\commonfunctions.php file.

Replace these lines:

$sSearchFor = 0+$sSearchFor;

$sSearchFor2 = 0+$sSearchFor2;

...

$value=0+$strvalue;

V
vivek author 10/6/2006

Hi there,
Thanks very much for the workarround, I tried the following replacements :
//$value=0+$strvalue;

$strvalue=substr($strvalue,0,strspn($strvalue,"01234567890.-"));

if(!strlen($strvalue))

$strvalue="0";

$value=$strvalue;
//$sSearchFor = 0+$sSearchFor;

$var2=substr($sSearchFor,0,strspn($sSearchFor,"01234567890.-"));

if(!strlen($var2))

$var2="0";

$sSearchFor = $var2;
//$sSearchFor2 = 0+$sSearchFor2;

$var2=substr($sSearchFor2,0,strspn($sSearchFor2,"01234567890.-"));

if(!strlen($var2))

$var2="0";

$sSearchFor2 = $var2;
After that I got the following error :
Technical information

Error type 256

Error description You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '='10215000000000002'' at line 1

URL beta.iisems.com/app/applications_list.php?mastertable=events&masterkey1=10215000000000002

Error file /home/iisemsc/public_html/beta/app/include/dbconnection.php

Error line 26

SQL query select `applid`, `evid`, `emsuserid`, `appldate`, `appltime`, `apllstatus`, `appremark`, `replremark` From `applications` where ='10215000000000002' ORDER BY `apllstatus` ASC, `appldate` ASC

Solution This is a general error. It occurs when there is an error in event code or in SQL.
Send your SQL or event code along with full error message tosupport@xlinesoft.com&.
Did I make a typo or forget something ?
Thanks,
Vivek

Admin 10/9/2006

Hi,
please zip and send to support@xlinesoft.com a full set of generated PHP pages along with your database creation script.

I'll find what's wrong with your project running it on my test box.