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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:40:31+00:00 2026-06-06T15:40:31+00:00

Since now I’ve been using the older mysql instead of PDO and I’ve seen

  • 0

Since now I’ve been using the older mysql instead of PDO and I’ve seen many recommendations why to switch to PDO, however also many different facts (also here on SO), e.g.:

  • stating PDO is slightly faster/a little bit slower
  • saying PDO helps prevent SQL-injections, but only if you use prepared queries
  • and also saying using prepared queries is bad, as it is damn slow

So, what is actually true? Especially, what are the best practices when using PDO and both speed and security matter a lot – how to best protect yourself from SQL injections while still having fast queries?

  • 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-06T15:40:32+00:00Added an answer on June 6, 2026 at 3:40 pm

    Database Support

    The core advantage of PDO over MySQL is in its database driver support. PDO supports many different drivers like CUBRID, MS SQL Server, Firebird/Interbase, IBM, MySQL, and so on.

    Security

    Both libraries provide SQL injection security, as long as the developer uses them the way they were intended. It is recommended that prepared statements are used with bound queries.

    // PDO, prepared statement
    $pdo->prepare('SELECT * FROM users WHERE username = :username');
    $pdo->execute(array(':username' => $_GET['username']));
    
    // mysqli, prepared statements
    $query = $mysqli->prepare('SELECT * FROM users WHERE username = ?');
    $query->bind_param('s', $_GET['username']);
    $query->execute();
    

    Speed

    While both PDO and MySQL are quite fast, MySQL performs insignificantly faster in benchmarks – ~2.5% for non-prepared statements, and ~6.5% for prepared ones.

    Named Parameters

    Just like @DaveRandom pointed out, this is another feature that PDO has, and it is considerably easier than than the horrible numeric binding.

    $params = array(':username' => 'test', ':email' => $mail, ':last_login' => time() - 3600);
    
    $pdo->prepare('
    SELECT * FROM users
    WHERE username = :username
    AND email = :email
    AND last_login > :last_login');
    
    $pdo->execute($params);
    

    PDO vs MySQL

    Few links for further reference
    MySQL vs PDO (Stackoverflow)
    Why you should be using PDO for database access (net.tutsplus.com)

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

Sidebar

Related Questions

I been using VS2008 Pro for a long time now but since of licensing
Since now, I'm using this loop to iterate over the elements of an array,
I've been working in ASP.NET for several years now (since the 1.0 days!), but
I can select the first item in the div using $('.class:first') Now since I
I'm executing an external script, using a <script> inside <head> . Now since the
Since now, I've been accessing box2d bodies (to change or to get their values)
Since now I have only used plugin for editing and the way I use
EDIT: This question is now redundant since Twitter no longer supports basic auth. I've
OK guys, up till now (and since I'm a beginner) I was programming Java
Since recent update Xcode 4.3 now seems to default to LLDB debugger. I just

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.