Question between PDO() and PDOStatement() classes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
PHPHelpNeeded
Forum Commoner
Posts: 83
Joined: Mon Nov 17, 2014 8:03 pm

Question between PDO() and PDOStatement() classes

Post 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?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

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

Post 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.
PHPHelpNeeded
Forum Commoner
Posts: 83
Joined: Mon Nov 17, 2014 8:03 pm

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

Post by PHPHelpNeeded »

Thank you.
Post Reply