When you use a PDO object and do a query, it returns a PDOStatement Object.
However, What I don't understand is, if you do print_r($s) ($r being the pdostatement) It prints out like an object, with no sign of a result.
However, you can do a foreach() on the object and loop through your results.
Can somebody explain to me whats going on?
I just wanted to do a print_r and view the array... nice and simple for testing. How can i do this?found it silly me
<!-- m --><a class="postlink" href="http://uk2.php.net/manual/en/function.pdostatement-fetchall.phpHowever">http://uk2.php.net/manual/en/function.p ... phpHowever</a><!-- m -->, you can do a foreach() on the object and loop through your results.
Can somebody explain to me whats going on?
To backup to this part of the question, I'm guessing that PDOStatement implements an iterator interface. Iterators were introduced in PHP 5, which allow you to iterate over an object using foreach(), and several of the new classes implement them. SimpleXML is another one that has an iterator (in addition to other new things like array access).Cool, thanks.
I don't really understand that method, or how you would recreate it in an object. but now I know what to read up on. Thanks
However, What I don't understand is, if you do print_r($s) ($r being the pdostatement) It prints out like an object, with no sign of a result.
However, you can do a foreach() on the object and loop through your results.
Can somebody explain to me whats going on?
I just wanted to do a print_r and view the array... nice and simple for testing. How can i do this?found it silly me
<!-- m --><a class="postlink" href="http://uk2.php.net/manual/en/function.pdostatement-fetchall.phpHowever">http://uk2.php.net/manual/en/function.p ... phpHowever</a><!-- m -->, you can do a foreach() on the object and loop through your results.
Can somebody explain to me whats going on?
To backup to this part of the question, I'm guessing that PDOStatement implements an iterator interface. Iterators were introduced in PHP 5, which allow you to iterate over an object using foreach(), and several of the new classes implement them. SimpleXML is another one that has an iterator (in addition to other new things like array access).Cool, thanks.
I don't really understand that method, or how you would recreate it in an object. but now I know what to read up on. Thanks