bonjour,
voila je voulais afficher une image par defaut sur ma page si il n'y a pas d'image mais je ne passe pas par le else alors que pour un des biens je n'ai pas d'image.
J'ai fait ceci:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
foreach($managerBien->getList(0,5) as $ListBien) 
			{
 
            $body.='<div class="offer_box">';
			 foreach($managerIllustration->getListPrincipaleById($ListBien->getId()) as $ListIllustration) 
				{
 
				if($managerIllustration->exists($ListBien->getId())!=0)
				{
				$body.='
            	<a href="details.html"><img src="'.RACINE.'/backend/illustrations/home/'.$ListBien->getReference().'/'.$ListIllustration->getLegende().'_home.jpeg" width="130" height="98" class="img_left" alt="" title="" border="0"/></a>';
				}
				else
				{
				$body.='sss
            	<a href="details.html"><img src="imagedefault_home.jpeg" width="130" height="98" class="img_left" alt="" title="" border="0"/></a>';
				}
				}
                $body.='<div class="offer_info">
                <span>Prix  150 000 $</span>
                <p class="offer">';
				$body.=''.substr($ListBien->getDescription(),0,50).'';             
                $body.='</p>
                <div class="more"><a href="details.html">...more</a></div>
                </div>
				
				
            </div>';
            }
?>
print_r($managerIllustration->exists($ListBien->getId())) me renvoie 1.
print_r($managerIllustration->getListPrincipaleById($ListBien->getId())) me renvoie
Array ( [0] => Illustration Object ( [erreurs:protected] => Array ( ) [id:protected] => 7 [legende:protected] => 1003V_1 [position:protected] => 1 [ref_bien:protected] => 7 ) )


les fonctions :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
public function getListPrincipaleById($id)
		{
 
		$listeIllustration = array();
 
		$sql = ('SELECT DISTINCT *
					FROM simplimmo_galerie
					INNER JOIN simplimmo_bien AS b ON simplimmo_galerie.ref_bien = b.id
					INNER JOIN simplimmo_bien ON simplimmo_galerie.ref_bien=simplimmo_bien.id
					WHERE simplimmo_galerie.ref_bien='.$id.' 
					and position="1"');
 
 
		$requete = $this->db->query($sql);
 
		while ($illustration = $requete->fetch(PDO::FETCH_ASSOC))
		$listeIllustration[] = new illustration ($illustration);
 
		$requete->closeCursor();
 
		return $listeIllustration;
 
		}
?>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
/**
		* Méthode vérifiant si l illustration existe
		* @param $email string
		* @return bool
		*/
	public function exists($id)
	{
 
		$requete = $this->db->prepare('SELECT COUNT(*) FROM simplimmo_galerie WHERE ref_bien = :id');
 
		$requete->execute(array(':id' => $id));
 
		return (bool) $requete->fetchColumn();
 
	}
?>
je comprend que les 2 fonctions renvoient une illustration, donc c'est cohérent mais comment faire alors?
merci.