real interview questions (PHP + MySQL PDO)

🔹 Basic Level Questions

  1. What is MySQL? Difference between SQL and MySQL?
  2. What is PDO in PHP? Why use it?
  3. Difference between MySQLi and PDO?
  4. What is a database table?
  5. What is a primary key?
  6. What is AUTO_INCREMENT?
  7. What is CRUD? Explain each operation.
  8. How do you connect PHP with MySQL using PDO?
  9. What is fetch() vs fetchAll()?
  10. What is PDO::FETCH_ASSOC?

🔹 Intermediate Level Questions

  1. What are prepared statements? Why are they important? 🔥
  2. What is SQL Injection? How do you prevent it?
  3. Difference between:
    • bindParam() vs bindValue()
  4. What is rowCount()?
  5. How to handle errors in PDO?
  6. What is lastInsertId()?
  7. What is the difference between:
    • require vs include (used in DB connection files)
  8. What is normalization in database?
  9. What are indexes in MySQL?
  10. What is the difference between INNER JOIN and LEFT JOIN?

🔹 Advanced Level Questions

  1. How does PDO protect against SQL Injection internally?
  2. What are transactions in PDO? Explain with example.
  3. Difference between:
    • commit()
    • rollback()
  4. How to optimize slow queries in MySQL?
  5. What is connection pooling?
  6. What is the difference between:
    • CHAR vs VARCHAR
  7. What is database locking?
  8. How do you secure user authentication system in PHP?
  9. What is hashing? Difference between:
    • md5()
    • password_hash() 🔥
  10. What are ACID properties in databases?

🔹 Practical Coding Questions (Very Important 🔥)

  1. Write a PDO query to insert user data securely
  2. Create a login system using prepared statements
  3. Fetch all users and display in table
  4. Update user email using PDO
  5. Delete a user by ID
  6. Create a search feature (LIKE query)
  7. Implement pagination in PHP + MySQL
  8. Build a secure registration system with hashed passwords
  9. Write a JOIN query using PDO
  10. Create a REST API using PHP + PDO

🔥 HR + Scenario-Based Questions

  1. What will you do if your database is hacked?
  2. How will you handle 1 million records efficiently?
  3. How do you design a scalable database?
  4. How do you debug a slow query?
  5. What steps will you take to secure a login system?

💡 Pro Tip (Interview Hack)

If you say this line, interviewer gets impressed:

“I always use PDO prepared statements with password_hash() and proper validation to prevent SQL injection and ensure security.”