This topic is locked
[SOLVED]

 Store empty fields

11/10/2010 4:33:56 AM
PHPRunner General questions
W
wpl author

Hi all,
this pertains to PHPRunner 5.2/5482. When I save data from a form that contains empty fields (validated as number), these fields are written as 0.0 to the database. This is not always a wanted behaviour, eg if you want to store temperature values, where 0.0 has got a meaning different from empty. How could I convince PHPRunner to just set the field content in the database to NULL if a numeric field is empty? I am using PostgreSQL as db and dal to store the values.
Thanks

Sergey Kornilov admin 11/11/2010

For some reason I'm not able to reproduce it. Probably I use a different field type or there something else that is different.
I suggest to post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.

W
wpl author 11/11/2010



For some reason I'm not able to reproduce it. Probably I use a different field type or there something else that is different.
I suggest to post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.


Sergey,
in the meantime the problem looks a bit different. If I leave the edit control in question empty during an add operation, everything is fine, because the respective field is not included in the update SQL string. If, however, I want to blank the field in the database (because the value was entered by mistake and the field should be empty) in edit mode, the old value in the db remains unchanged because the field is not part of the update string as mentioned above. Unfortunately, I can't publish the project because the db is only accessible by localhost. Any idea?
Thanks

J
Jane 11/11/2010

Hi,
you can check entered value in the After record added/After record updated events on the Eventstab and update this field if needed.

Here is just a sample:

if (!$values["FieldName"]) //if entered value is empty string

{

//update database with NULL value

$strUpdate = "update TableName set FieldName=NULL where IDField=".$keys["IDField"];

CustmQuery($strUpdate);

}
W
wpl author 11/11/2010



Hi,
you can check entered value in the After record added/After record updated events on the Eventstab and update this field if needed.

Here is just a sample:

if (!$values["FieldName"]) //if entered value is empty string

{

//update database with NULL value

$strUpdate = "update TableName set FieldName=NULL where IDField=".$keys["IDField"];

CustmQuery($strUpdate);

}



Jane,
thanks for the answer. That's what I have been thinking of also. Just thought there was kind of a switch in dal to force it to set the fields for empty controls to NULL.
regards