protected function _associateManyToMany($row, $many_to_many)
{
$pdo = $this->_phactory->getConnection();
foreach ($many_to_many as $name => $arr) {
list($to_rows, $assoc) = $arr;
foreach ($to_rows as $to_row) {
$join_table = $assoc->getJoinTable();
$from_join_column = $assoc->getFromJoinColumn();
$to_join_column = $assoc->getToJoinColumn();
// Quote table names as underlying DB expects it
$sql = "INSERT INTO " . $this->_table->quoteIdentifier($join_table) . "\n (" . $this->_table->quoteIdentifier($from_join_column) . ", " . $this->_table->quoteIdentifier($to_join_column) . ")\n VALUES\n (:from_id, :to_id)";
$stmt = $pdo->prepare($sql);
$r = $stmt->execute(array(':from_id' => $row->getId(), ':to_id' => $to_row->getId()));
if ($r === false) {
$error = $stmt->errorInfo();
Logger::error('SQL statement failed: ' . $sql . ' ERROR MESSAGE: ' . $error[2] . ' ERROR CODE: ' . $error[1]);
}
}
}
}