Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3664150
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:36:48+00:00 2026-05-19T01:36:48+00:00

I am newbie with PDO libraries. I am working on development environment with mysql

  • 0

I am newbie with PDO libraries. I am working on development environment with mysql as my database. I am able to run through my queries using prepare and execute function while using “?” placeholder and also bindParam method while using named placeholders (ex: “:column”).

After this I tried to see if PDO does any kind of escaping by putting in any quotes to sanitize the query like mysql_real_escape_string does. I am trying to see what would the query look but all I get is the statement that has been passed into the prepare statement, but not the query that would be executed.

I tried to var_dump the $result->execute(), and $result->fetch() but the execute statement gives me my prepare statement’s sql with place holders while fetch statement gives me the result of that query.

Is there a way to look at the find query that would be run, or atleast how the parameters would look before running the query??

I hope I am clear with my question. 😐

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T01:36:49+00:00Added an answer on May 19, 2026 at 1:36 am

    When you write something like:

    $stmt = $pdo->prepare('SELECT * FROM tbl_name WHERE col_name = :col_name;');
    $stmt->bindValue('col_name', 'some \' value');
    $stmt->execute();
    

    The actual query is… SELECT * FROM tbl_name WHERE col_name = :col_name;. That’s called prepared statement. Firstly, you send query to the database, later you send query parameters. PDO doesn’t merge query and parameters.

    You’ve probably thought that PDOStatement::bindValue() does something like:

    public function bindValue($placeholer, $value, $valueType = PDO::PARAM_STR) {
        $this->query = str_replace($placeholder, $this->quote($value, $valueType), $this->query);
    }
    

    But it doesn’t.

    It does something more like that:

    public function execute() {
        try {
            $this->sendQueryToDatabase($this->query);
    
            // Query is valid
            $this->sendParametersToDatabase($this->parameters);
    
            return $this->fetchResultSet();
        } catch (... $e) {
            // Query is invalid (eg. syntax error)
            throw ...;
        }
    }
    

    Read more about Prepared Statements

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been told that I'd be better using PDO for MySQL escaping, rather than
Newbie question. I’m writing an ASP.Net MVC app in VB.Net and have been using
newbie to iPhone game development and Box2D here. I'm developing a game in which
Newbie question. I have a NSMutableArray that holds multiple objects (objects that stores Bezier
Newbie to LINQ, and trying to write the following query... select f.Section_ID, f.Page_ID, f.SortOrder,
Newbie here...can I write one program which incorporates .NET LINQ and also various Java
Java Newbie here. I have a JFrame that I added to my netbeans project,
.NET newbie here... I'd like to make a button in a Windows form that
Total newbie question but this is driving me mad! I'm trying this: myInt =
I'm a newbie to pgsql. I have few questionss on it: 1) I know

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.