Time exception exception in coldfusion query in cfc and mySQL

I am moving from the MS Access firewall to mySQL. It worked, but now it doesn’t, and I cannot understand the problem.

<cfargument required="false" name="expiry" type="any" default="" />


        <cfquery datasource='#arguments.dsn#'>      
            INSERT INTO users(expiry)
            VALUES (<cfqueryparam value="#arguments.expiry#" cfsqltype="CF_SQL_TIMESTAMP"/>)
        </cfquery>  

Database field set to datetime and defaults to NULL

The argument is populated from a form field that is either empty or a date confirmed by javascript. He gasps in the empty form field.

+5
source share
2 answers

Before you come across DSN settings, I will also try changing yours <cfqueryparam>to the following:

<cfqueryparam value="#arguments.expiry#" cfsqltype="CF_SQL_TIMESTAMP" null="#len(arguments.expiry) eq 0#" />

This will give true null if the argument value is an empty string.

+6
source

CF- JDBC MySQL NULL.

DSN ( ) CF admin

& zeroDateTimeBehavior = convertToNull

.

Rob

+1

All Articles