$sql = \'INSERT INTO `\' . $table_name . \'` \'
. \'(`day`, `campaign_name`, `campaign_id`, `views`, `CPM`, `cost`, `currency`, `cost_EUR`) VALUES \'
You only need to pass an array to the execute method. So your updated code would look like this:
$sql = 'INSERT INTO `' . $table_name . '` '
. '(`day`, `campaign_name`, `campaign_id`, `views`, `CPM`, `cost`, `currency`, `cost_EUR`) VALUES '
. '(:day, :campaign_name, :campaign_id, :views, :CPM, :cost, :currency, :cost_EUR)';
$sth = $this->_dbi->prepare($sql);
$sth->execute(array(
':day' => $day,
':campaign_name' => $campaignName,
':campaign_id' => $campaignID,
':views' => $views,
':CPM' => $cpm,
':cost' => $cost_EUR,
':currency' => 'EUR',
':cost_EUR' => $cost_EUR
));
Read more here: http://php.net/manual/en/pdostatement.execute.php
PDOStatement::execute — Executes a prepared statement
Usage: public bool PDOStatement::execute ([ array $input_parameters ] )
Here is the example from the documentation:
prepare('SELECT name, colour, calories FROM fruit WHERE calories < :calories AND colour = :colour'); $sth->execute(array(':calories' => $calories, ':colour' => $colour));