Podrzucam kod zapytania:
<?php
$sql="UPDATE ".DB_PREFIX."shop_products SET ss_id=:style,sc_id=:category,
sp_title=:title,sp_author=:author,
sp_text_author=:textAuthor,
sp_music_author=:musicAuthor,sp_tags=:tags,sp_shortdesc=:desc,sp_longdesc=:songT
ext,sp_normal_price=:normalPrice,
sp_special_price=:specialPrice,sp_send_price=:sendPrice,";
if ($photo) {
foreach ($photo as $id=>$key) {
if ($id == 0)
$sql.="sp_photo_path=:photo,";
else
$sql.="sp_photo_path".$id."=:photo_".$id.",";
}
}
if ($sample)
$sql.="sp_short_path=:shortMp3,";
if ($full)
$sql.="sp_long_path=:fullMp3,";
if ($isclip)
$sql.="sp_clip=:clip,";
$sql.="sp_promotion=:promotion,sp_adult=:adult, sp_date_of_add=now() WHERE sp_id=:sp_id";
//exit(0);
try{
$stm=$this->db->prepare($sql);
$stm->bindParam(':style',$_POST['style'],PDO::PARAM_INT);
$stm->bindParam(':category',$_POST['category'],PDO::PARAM_INT);
$stm->bindParam(':title',$_POST['title'],PDO::PARAM_STR);
$stm->bindParam(':author',$_POST['author'],PDO::PARAM_STR);
$stm->bindParam(':textAuthor',$_POST['author-text'],PDO::PARAM_STR);
$stm->bindParam(':musicAuthor',$_POST['author-music'],PDO::PARAM_STR);
$stm->bindParam(':tags',$_POST['tags'],PDO::PARAM_STR);
$stm->bindParam(':desc',$_POST['desc'],PDO::PARAM_STR);
$stm->bindParam(':songText',$_POST['song-text'],PDO::PARAM_STR);
$stm->bindParam(':normalPrice',$_POST['price-norm'],PDO::PARAM_STR);
if (isset($_POST['price-prom'])) $stm->bindParam(':specialPrice',$_POST['price-prom'],PDO::PARAM_STR);
if (isset($_POST['sendPrice'])) { $sendprice=(bool)$_POST['sendPrice'];
$stm->bindParam(':sendPrice',$sendprice,PDO::PARAM_BOOL);
}
if ($photo) {
foreach ($photo as $id=>$key) {
$path=$this->photoDir.$key;
//echo $path;
if ($id == 0){
$stm->bindParam(':photo',$path,PDO::PARAM_STR);
}
else
$stm->bindParam(':photo'.$id,$path,PDO::PARAM_STR);
}
}
if (!$isclip)
$stm->bindParam(':clip',$_POST['clip'],PDO::PARAM_STR);
if ($sample)
$stm->bindParam(':shortMp3',$sample,PDO::PARAM_STR);
if ($full)
$stm->bindParam(':fullMp3',$full,PDO::PARAM_STR);
if(isset($_POST['promotion'])) { $prom=(bool)$_POST['promotion'];
$stm->bindParam(':promotion',$prom,PDO::PARAM_BOOL);
}
if (isset($_POST['adult'])) { $adul=(bool)$_POST['adult'];
$stm->bindParam(':adult',$adul,PDO::PARAM_BOOL);
}
$stm->bindParam(':sp_id',$_GET['p_id'],PDO::PARAM_INT);
if ($stm->execute() == false)
return false;
} catch(PDOException $e) {
throw new PDOException($e->getMessage());
}
?>
Chce aby to zapytanie wywolalo sie raz w calosci. Tak sie sklada ze znam max ilosc elementow z tablicy $photo i moge to zastapic np :
<?php
$path=$this->photoDir.$photo[0];
$stm->bindParam(':photo',$path,PDO::PARAM_STR);
}
$path1=$this->photoDir.$photo[1];
$stm->bindParam(':photo_1',$path1,PDO::PARAM_STR);
}
$path2=$this->photoDir.$photo[2];
$stm->bindParam(':photo_2',$path2,PDO::PARAM_STR);
}
$path3=$this->photoDir.$photo[3];
$stm->bindParam(':photo_3',$path3,PDO::PARAM_STR);
}
$path4=$this->photoDir.$photo[4];
$stm->bindParam(':photo_4',$path4,PDO::PARAM_STR);
?>
ale to nie jest optymalnym i cieszacym mnie rozwiazaniem:(