<?php
public function add_albums($band_id,$albums)
{
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);
if(!$query->execute())
return false;
}
return true;
}
?>
PD9waHAKICAgIHB1YmxpYyBmdW5jdGlvbiBhZGRfYWxidW1zKCRiYW5kX2lkLCRhbGJ1bXMpCgl7CgkJCWZvciAoJGk9MCA7ICRpPGNvdW50KCRhbGJ1bXMpOyAkaSsrKQoJCQl7CgkJCQkJJGFsYnVtX2lkPSRhbGJ1bXNbJGldOwoJCQkJCSRzdHJpbmc9IklOU0VSVCBJTlRPIGBiYW5kc19hbGJ1bXNgIChgYmFuZF9pZGAsYGFsYnVtX2lkYCkgVkFMVUVTICg6YmFuZF9pZCw6YWxidW1faWQpIjsKCQkJCQkkcXVlcnk9JHRoaXMtPmRiLT5wcmVwYXJlKCRzdHJpbmcpOwoJCQkJCSRxdWVyeS0+YmluZFZhbHVlKCc6YmFuZF9pZCcsICRiYW5kX2lkLCBQRE86OlBBUkFNX0lOVCk7CgkJCQkJJHF1ZXJ5LT5iaW5kVmFsdWUoJzphbGJ1bV9pZCcsICRhbGJ1bV9pZCwgUERPOjpQQVJBTV9JTlQpOwoJCQkJCWlmKCEkcXVlcnktPmV4ZWN1dGUoKSkKCQkJCQkJcmV0dXJuIGZhbHNlOwoJCQl9CgkJCXJldHVybiB0cnVlOwoKCX0KPz4=