Forum Moderators: open
$foo = param('foo');
my $sth = $dbh->do("INSERT INTO table (colA)
VALUES (?)", undef,
$foo) or die "Couldn't execute INSERT: " . $dbh->errstr; $foo = param('foo');
if (!$foo) { $foo = ''; }
my $sth = $dbh->do("INSERT INTO table (colA)
VALUES (?)", undef,
$foo) or die "Couldn't execute INSERT: " . $dbh->errstr;
Avoid Null if possible.
...
It's harder for MySQL to optimize queries that refer to nullable columns, because they make indexes, index statistics, and value comparisons more complicated. A nullable column uses more storage space and requires special processing inside MySQL.