Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.