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.