I'm trying to do this:
$sth = $dbi->prepare('INSERT INTO table VALUES (?, ?, ?)');
$sth->execute(
$var1,
$var2 || 'NOW()',
$var3
);
without any luck. Any ideas?
I'm trying to do this:
$sth = $dbi->prepare('INSERT INTO table VALUES (?, ?, ?)');
$sth->execute(
$var1,
$var2 || 'NOW()',
$var3
);
without any luck. Any ideas?
Functions cannot be bound parameters. MySQL will enclose them in quotes which is not valid syntax.
Your options are:
$now = time2str('%Y-%m-%d %T', time);
$sth = $dbi->prepare('INSERT INTO table VALUES (?, COALESCE(?, NOW()), ?)');
$sth->execute(
$var1,
$var2,
$var3
);
Dear Friend,
You can use the following coding also.
$sth = $dbi->prepare('INSERT INTO table VALUES (?, COALESCE(?, NOW()), ?)');
$sth->bind_param($var1,$var2,$var3);
$sth1=$sth->execute;