<?php
public function add_albums($band_id,$albums)
{
try
{
for ($i=0 ; $i<count($albums); $i++) {
$album_id=$albums[$i];
$string="INSERT INTO `bands_albums` (`band_id`,`album_id`) VALUES (:band_id,:album_id)";
$query=$this->db->prepare($string);
$query->bindValue(':band_id', $band_id, PDO::PARAM_INT);
$query->bindValue(':album_id', $album_id, PDO::PARAM_INT);
$query->execute();
}
}
catch (PDOException $e)
{
echo 'add_albums: ' . $e->getMessage();
}
}
?>
PD9waHAKICAgIHB1YmxpYyBmdW5jdGlvbiBhZGRfYWxidW1zKCRiYW5kX2lkLCRhbGJ1bXMpCgl7CgkJdHJ5CgkJewoJCQlmb3IgKCRpPTAgOyAkaTxjb3VudCgkYWxidW1zKTsgJGkrKykKCQkJewoJCQkJCSRhbGJ1bV9pZD0kYWxidW1zWyRpXTsKCQkJCQkkc3RyaW5nPSJJTlNFUlQgSU5UTyBgYmFuZHNfYWxidW1zYCAoYGJhbmRfaWRgLGBhbGJ1bV9pZGApIFZBTFVFUyAoOmJhbmRfaWQsOmFsYnVtX2lkKSI7CgkJCQkJJHF1ZXJ5PSR0aGlzLT5kYi0+cHJlcGFyZSgkc3RyaW5nKTsKCQkJCQkkcXVlcnktPmJpbmRWYWx1ZSgnOmJhbmRfaWQnLCAkYmFuZF9pZCwgUERPOjpQQVJBTV9JTlQpOwoJCQkJCSRxdWVyeS0+YmluZFZhbHVlKCc6YWxidW1faWQnLCAkYWxidW1faWQsIFBETzo6UEFSQU1fSU5UKTsKCQkJCQkkcXVlcnktPmV4ZWN1dGUoKTsJCQoJCQl9CgkJfQoJCWNhdGNoIChQRE9FeGNlcHRpb24gJGUpCgkJewoJCQllY2hvICdhZGRfYWxidW1zOiAnIC4gJGUtPmdldE1lc3NhZ2UoKTsKCQl9Cgl9Cj8+