Hi there guys!
I’m trying to figure out why my PDO query intended to get all rows in a table is only returning the first row.
/* Retrieve current list of servers, both for server count and ip/port/name check */
$stmt = $pdo1->prepare("SELECT * FROM servers");
$stmt->execute();
$serverlist[] = $stmt->fetch(PDO::FETCH_ASSOC);
if($serverlist == NULL){
echo 'serverlist is null.';
}else{
print_r($serverlist);
}
exit;
There’s two rows in the table but when I execute the script, I get only the first row in the table:
Array
(
[0] => Array
(
[id] => 1
[name] => Demo
[safename] => demo
[ip] => domain.com
[port] => 30120
[dbhost] => 127.0.0.1
[dbname] => demo
[dbuser] => user
[dbpass] => pass
[framework] => none
)
)
Could someone tell me what I’m doing wrong?
Thanks for your time!