Reputation: 19
I have been struggling for 3 days but cannot get a simple solution.
$asup = $connection->prepare('
update company_assign set
post = :post,
shift_start = :shift_start,
shift_end = :shift_end,
');
$asup->bindParam(':post', $_POST['post']);
$asup->bindParam(':shift_start', $_POST['start']);
$asup->bindParam(':shift_end', $_POST['end']);
$asup->execute();
It's Working Perfectly, But I want to Pass NULL if any of $_POST arrary having NULL or Empty member.
Please help me to define correct binding statement. Previous days it seemed like this:
$asup->bindParam(':shift_start', $_POST['start'], NULL);
But now it's not working with PHP 8.1, please share if you have any idea. Thanks
Upvotes: -2
Views: 44
Reputation: 15057
use this to set NULL parameter
$asup->bindParam(':shift_end', $shift_end, $shift_end === NULL ? PDO::PARAM_NULL : PDO::PARAM_STR);
Upvotes: 0