| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 
 |  
	public function fetchAll() {
		Zend_Loader::loadClass("Zend_Db_Select");
		$db = Zend_Registry::get("dbAdapter");
		$db->query("PRAGMA full_column_names = 1");
		$db->query("PRAGMA short_column_names = 0");	
		$select = $db->select()
			->from('news', array('news.id', 'titre', 'texte', 'dateajout'))
			->from('users','username')
			->joinLeft('commentnews', 'news.id = commentnews.idnews', 'COUNT(DISTINCT commentnews.id) as nbcomments')
			->joinLeft('historique_news','news.id = historique_news.idnews',"MAX(datemaj) as datemaj")
			->group('news.id')
			->where('news.iduser = users.id')
			->order('news.dateajout DESC');
		$stmt = $db->query($select);
		$result = $stmt->fetchAll();
		return $result;
	} | 
Partager