what is the best practice for inserting only fields that are filled out in a form into a database dynamically so it's not adding empty fields that overide my mysql defaults?😕
example:
'bs' is empty so I don't want to insert an empty value.
try {
$db = new PDO("mysql:dbname=DBName ;host=Host" ,User , Password );
echo "PDO connection object created";
}
catch(PDOException $e)
{
echo $e->getMessage();
}
$params = array('ptr' => '29', 'bs' => '');
$stmt = $db->prepare('INSERT INTO foo (bar_Id, bar_size) VALUES (:ptr, :bs)');
$stmt->execute($params);
$stmt->fetch(PDO::FETCH_BOUND);
print_r($stmt);