getDbMySQL(), "photo"); $queryBuilder->addField("photo_" . $size, "photo"); $queryBuilder->addField("filename"); $queryBuilder->addWhereEquals("id", $_REQUEST['id']); $result = $this->getDbMySQL()->select($queryBuilder->toQuery()); if( $result->numRows() == 1 ) { $row = $result->fetchAssoc(); header("Content-type: image/jpeg"); if( strlen($row['filename']) > 0 ) { header("Content-disposition: inline; filename=\"" . $row['filename'] . "\""); }else { header("Content-disposition: inline; filename=\"Photo-" . $_REQUEST['id'] . ".jpg\""); } echo $row['photo']; $result->freeResult(); }else { /** No photo found, show error picture */ header("Content-type: image/png"); $im = ImageCreate(120, 50); $background_color = ImageColorAllocate($im, 104, 103, 222); $text_color = ImageColorAllocate($im, 242, 186, 47); ImageString($im, 2, 5, 5, "Photo " . $_REQUEST['id'] . " (" . $size . ")", $text_color); ImageString($im, 2, 5, 20, "not found", $text_color); ImagePNG($im); ImageDestroy($im); } } } new Photo(); ?>