PDA

View Full Version : PULLIN MY HAIR OUT! stumped on $db->query_first


Antivirus
06-10-2006, 12:06 PM
I have a query which works fine returning all my data using following method:
$sql = "
SELECT erc_artist.*, erc_artisttype.artisttype, MIN(erc_artistimage.artistimageid) AS artistimageid
FROM erc_artist
LEFT JOIN erc_artisttype ON erc_artist.artisttypeid = erc_artisttype.artisttypeid
LEFT JOIN erc_artistimage ON erc_artist.artistid = erc_artistimage.artistid
WHERE artistisactive = '1'
GROUP BY erc_artisttype.displayorder, artisttitle
";


But when i try to use the following $db->query_first method i get nada!
$sql = $db->query_first("
SELECT erc_artist.*, erc_artisttype.artisttype, MIN(erc_artistimage.artistimageid) AS artistimageid
FROM erc_artist
LEFT JOIN erc_artisttype ON erc_artist.artisttypeid = erc.artisttype.artisttypeid
LEFT JOIN erc_artistimage ON erc_artist.artistid = erc_artistimage.artistid
WHERE artistisactive = '1' AND erc_artistimage.image_type = 'artistpicture'
GROUP BY erc_artisttype.displayorder, artisttitle
");


Does anyone know what i am doing wrong here?

calorie
06-10-2006, 03:35 PM
Try... $db->query_read($sql);

Adrian Schneider
06-10-2006, 05:24 PM
$db->query_read() returns the MySQL result.

$db->query_first() returns the fetched array (and frees the MySQL result). This only works for single rows.

Antivirus
06-10-2006, 09:42 PM
Thanks for the assistance Calorie & SirAdrian, the following works for me :)
I'm still getting used to vb's objects, taking me some time but persistance is my best learning aid... and the vborg community :banana:



$qryartists = $db->query_read("
SELECT erc_artist.*, erc_artisttype.artisttype, MIN(erc_artistimage.artistimageid) AS artistimageid
FROM erc_artist
LEFT JOIN erc_artisttype ON erc_artist.artisttypeid = erc_artisttype.artisttypeid
LEFT JOIN erc_artistimage ON erc_artist.artistid = erc_artistimage.artistid
WHERE artistisactive = '1'
GROUP BY erc_artisttype.displayorder, artisttitle
");