Witam.
napisalem taka funkcje prosta do poboru id za pomoca pdo, jednak funkcja fetchAll nie dziala jak kozystam wczesniej z fetchColumn. Musze od nowa tworzyc zapytanie, co jest troche bez sensu :/
Jaka jest na to rada ?


function getArtistId($artist)
{
$pdo = $this->connectToDB();
$artist_data = $pdo->prepare("SELECT artist_id from album_artists WHERE artist_name = :artist_name");
$artist_data->bindParam(":artist_name", $artist);
$artist_data->execute();
if($artist_data->fetchColumn() == 0)
{
return false;
}else{


//$artist_data = $pdo->prepare("SELECT artist_id from album_artists WHERE artist_name = :artist_name"); -- dziala tylko z tym
//$artist_data->bindParam(":artist_name" , $artist); -- dziala tylko z tym
//$artist_data->execute(); -- dziala tylko z tym
$artist_result = $artist_data->fetchAll();
foreach($artist_result as $row)
{
echo " artist id: ";
echo $row['artist_id'];
$artist_id = $row['artist_id'];
}
return $artist_id;
}
}

spoko, juz sobie poradzilem. smile.gif
trzeba zrobic to tak :
  1.  
  2. function getArtistId($artist)
  3. {
  4. $pdo = $this->connectToDB();
  5. $artist_data = $pdo->prepare("SELECT artist_id from album_artists WHERE artist_name = :artist_name");
  6. $artist_data->bindParam(":artist_name", $artist);
  7. $artist_data->execute();
  8. $artist_result = $artist_data->fetchAll();
  9. if (count($artist_result) == 0)
  10. {
  11. return false;
  12. }else{
  13. foreach($artist_result as $row)
  14. {
  15. $artist_id = $row['artist_id'];
  16. }
  17. return $artist_id;
  18. }
  19. }
  20.  
  21.  
  22.  
  23.  
  24.  


elo.