Problem extracting object details

I have a problem extracting contents of an object. Duplicated record is being displayed and I don’t seem to get my head around it as whether to use foreach or while or even for loops. here is a var_dump result:

array(12) { [0]=> string(1) "1" ["id"]=> string(1) "1" [1]=> string(6) "Tenzo" ["first_name"]=> string(6) "Tenzoi" [2]=> string(8) "Kemp" ["last_name"]=> string(8) "Kemp" [3]=> string(18) "tkemp@yahoo.com" ["email"]=> string(18) "tkemp@yahoo.com" [4]=> string(32) "84792b4ce332bfc4d0e12edd443d19ec" ["password"]=> string(32) "84792b4ce332bfc4d0e12edd443d19ec" [5]=> string(5) "admin" ["role"]=> string(5) "admin" 

As you can see the same record is displaying twice…

These are the functions envolved:


//find all
public static function findAll(){
        return self::findBySQL("SELECT * FROM users");
}

//find by sql
public static function findBySQL($sql){
        global $dbh;
        
        $r = $dbh->query($sql);
        
        $row = $dbh->fetchArray($r);
        
        return $row;
}

And I’m calling it like so:

$r = User::findAll();
var_dump($r);

You to select a “fetch style”, check the parameters at the manual. :wink: