Before I insert a row, I want to check for its existence, in order to avoid duplicates.
So, I
$pdo = ConenctToDatabase();
// Check for existence - don't add a duplicate
$sqlQuery = $pdo->prepare('SELECT campaign_id FROM campaigns WHERE (customer_id=:$customerId) AND (title=:campaignTitle) AND (description=:campaignDescription) AND (start_time=:startTimeStamp) AND (end_time=:endTimeStamp)');
$sqlQuery->bindParam(':customerId', $customerId, PDO::PARAM_INT);
$sqlQuery->bindParam(':campaignTitle', $campaignTitle);
$sqlQuery->bindParam(':campaignDescription', $campaignDescription);
$sqlQuery->bindParam(':startTimeStamp', $campaignTitle);
$sqlQuery->bindParam(':endTimeStamp', $endTimeStamp);
If it doesn't already exist, I want to reuse the PDO statement, changing the SELECT to an INSERT.
The INSERT takes identical parameters. Do I have to bind them again after the second prepare
?