Page 1 of 1

Question between PDO() and PDOStatement() classes

Posted: Sat Nov 29, 2014 1:32 pm
by PHPHelpNeeded
When you connect to the database or the db server, do you create an instance of both classes the PDO() and the PDOStatement()?

If not, how do you perform a query with PDO() and then fetch the information with PDOStatement()?

How do you make the connection that the two instance relate to each other?

Re: Question between PDO() and PDOStatement() classes

Posted: Sat Nov 29, 2014 3:02 pm
by Celauran
You instantiate the PDO class. A PDOStatement object will be returned when you perform PDO::query or PDO::prepare. You shouldn't need to instantiate PDOStatement directly.

Re: Question between PDO() and PDOStatement() classes

Posted: Sat Nov 29, 2014 4:16 pm
by PHPHelpNeeded
Thank you.