After looking at your code, I think this is your problem:
public static function getScrapedSites($db) {
$query = "select * from sites";
$result = $db->query($query);
$scrapedSites = $result->fetch_assoc();
return $scrapedSites;
}
I believe this will always return a single row. You need to loop over the results with fetch_assoc()
and append the results to an array.
public static function getScrapedSites($db) {
$query = "select * from sites";
$result = $db->query($query);
$scrapedSites = array();
foreach($result->fetch_assoc() as $site) {
$scrapedSites[] = $site;
}
return $scrapedSites;
}
You said that $site
was outputting a string in your example. This is because your foreach
loop was iterating over the db fields in the associative array.