| 
				
				
				
				 | 
			
			 | 
			@@ -0,0 +1,53 @@ | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			<?php | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			namespace Dao; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			class | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			Thread | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			{ | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  public function | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  get_threads ( | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      SQLite3 $db) | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  : array | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    $sql = " | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        SELECT | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          t.id, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          t.title, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          t.explain, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          MAX(r.date) AS latest | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        FROM | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          threads AS t | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          LEFT OUTER JOIN | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            responses AS r | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            ON | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			              r.threads_id = t.id | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        WHERE | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          t.id <> 1 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          -- AND t.deleted = 0 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        GROUP BY | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          t.id | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        ORDER BY | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          latest DESC"; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    $result = $db -> query ($sql); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    $threads = []; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    while (($row = $threads -> fetchArray (SQLITE3_ASSOC)) !== false) | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        $thread = new Dto\Thread; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        $thread -> id = $row['id']; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        $therad -> title = $row['title']; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        $thread -> explain = $row['explain']; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        $thread -> latest = $row['latest']; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        $threads[] = $thread; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    return $therads; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			} | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  |