This topic is locked

Forcing NULL if empty

6/17/2006 11:03:34 PM
PHPRunner General questions
J
jenolan author

OK I is registered now .. heaven help the planet!
Anyway .. still fiddling away, I changed some database info and now where I was defaulting a value I want it NULL if empty. Changed the database if I do an insert form there the fields are null but not via the PR I checked the fields they seem setup ok but I can't get a null :-)
Ta! .. Larry

Alexey admin 6/19/2006

Larry,
you can do using Before record added event.

Here is the sample code to insert NULL instead of empty string:

if($values["Field1"]=="")

$values["Field1"]="null";

if($values["Field2"]=="")

$values["Field2"]="null";

where Field1 and Field2 are your actual field names.

J
jenolan author 6/19/2006

you can do using Before record added event.

Here is the sample code to insert NULL instead of empty string:


Actually this is needed .. thanks for the pointer!

if( $values[ "Asset_Auran_Link" ] == "''" )

{

$values[ "Asset_Auran_Link" ] = "null";

}


That's " then two ' then another "