Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Using PHP with MySQL Filtering Input for Queries Preparing SQL Statements

Philip Bradbury
Philip Bradbury
33,368 Points

Issue finding details on methods

Ive been trying to find some more details on methods... notable the query() and prepare() methods. On searching the PHP manual I can't find any details . I come across the PDO::prepare which I thought could be is and it is a method of PDO but it doesn't hold a lot of information to explain what prepare is. Any ideas/help on what i need to search to find ->query and ->prepare??

1 Answer

Andrew Shook
Andrew Shook
31,709 Points

Phillip, PDO::prepare is the method you are looking for. I'm not sure why they use the scope resolution operator ( the double colons) in the documentation for classes, but it roughly translates to the same thing as (->). However, in code the do mean different things so do use them interchangeably. This is a good page to look over for binding and preparing. What questions about the prepare method do you have?

EDIT: Noticed a few typos in my answer that might cause some problems. "::" and "->" DO NOT mean the same thing when writing code so DO NOT use them interchangeably.

Philip Bradbury
Philip Bradbury
33,368 Points

Thanks Andrew for that, might need to look into scope resolution operators.