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 8509377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:25:05+00:00 2026-06-11T03:25:05+00:00

Currently, I am developing my first website. Right now, I am implementing PHP’s MySQL

  • 0

Currently, I am developing my first website. Right now, I am implementing PHP’s MySQL extensions. From what I’ve been reading, however, using PHP’s PDO would be a much better way to go for several reasons such as the use of placeholders and so forth.

After going over some of the code, I am curious about a few things. As an example, say I create a connection and query as such:

$pdo = new PDO('mysql:host=localhost;dbname=something','root','abc');

$sql="select id from users where username = :username and password = :password";

$stmt = $pdo->prepare($sql);

$stmt->bindParam(":username",$_POST['username']);
$stmt->bindParam(":password",$_POST['password']);

$stmt->execute();

First, does $stmt->execute(); actually execute the entire query? And if so, why? If that is the case, my assumption would be that, in a way, it is inherently connected to the the prepared statements and therefore it is binded to the prepared sql statement.

Also, it is quite obvious that prepared statements are better protected against sql injection. My questions is at what point is user input sanitized within PDO. To explain, in the MySQL extensions, functions such as mysql_real_escape_string() had to be hardcoded when sanitizing.

If there are any other intricacies of using PDO that don’t exist when using MySQL extensions, I am curious to know.

Any feedback is appreciated.

  • 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-06-11T03:25:07+00:00Added an answer on June 11, 2026 at 3:25 am

    Also, it is quite obvious that prepared statements are better protected against sql injection. My questions is at what point is user input sanitized within PDO. To explain, in the MySQL extensions, functions such as mysql_real_escape_string() had to be hardcoded when sanitizing.

    Ideally, it’s delivered directly to the database driver as data (alliteration! Awesome, always). However, if PDO has to emulate prepared statements, then it’s done when the query is executed.

    First, does $stmt->execute(); actually execute the entire query? And if so, why? If that is the case, my assumption would be that, in a way, it is inherently connected to the the prepared statements and therefore it is binded [sic] to the prepared sql statement.

    Yes. $stmt->execute() is connected to $stmt because you’re calling it on $stmt. I’m not really sure how to further explain that.

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

Sidebar

Related Questions

Currently developing a PHP framework and have ran into my first problem. I need
I'm currently developing a website. Every feature works fine. However, I'm using a lot
I'm currently developing my first android app, and my first game. I've been developing
I am currently developing a new website and have problems with IE7. First image
I am currently developing my first Android application by reading Dev Documentation at Android
I have a website say www.livesite.com which is currently running. I have been developing
I am currently developing a website and i need that the pages loads dynamically
I'm currently developing a PM system for a website, in which users must be
I am developing a website that has some sort of realtime update. Now the
I'm currently developing a website which will have heavy load, and a certain amount

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.