Brain blank on how to retrieve from an array

I am having a brain fart in trying to retrieve data from an array:

here is the print_r() of it:

DB Object

(
[_pdo:DB:private] => PDO Object
(
)

[_query:DB:private] => PDOStatement Object
    (
        [queryString] => SELECT * FROM employers WHERE id = ?
    )

[_error:DB:private] => 
[_results:DB:private] => Array
    (
        [0] => stdClass Object
            (
                [id] => 2
                [employer] => SimpeQ
                [address] => 
                [city] => 
                [province] => 
                [country] => 
                [postalcode] => 
                [phone] => 
                [fax] => 
                [email] => 
            )

    )

[_count:DB:private] => 1

)

i want to echo [employer] on my page. how can I extract it from the array?

I figured it out: it was silly.

only had to add the following after the query:

foreach($sql->results() as $row)
echo $row->employer

2 Likes

I still a little surprised that you can access that array with the word private in the output.

When a property is protected or private it can still be reached if a __get or __set is implemented to reach it.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.