Subjects

All subjects Django Java Python React Spring Boot JavaScript PHP
Sign Up Free
PHP 10 questions

Database Connectivity (MySQLi/PDO)

Master database interactions in PHP. Learn prepared statements, PDO bindings, transaction safety, and performance optimization.

More PHP
Interview questions 1–10 of 10
1

What is the difference between MySQLi and PDO in PHP?

Both are database extensions for connecting PHP to databases, but they differ in scope and features.FeatureMyS...

Read answer →
2

How do you connect to a MySQL database using PDO?

Create a new PDO instance with a DSN (Data Source Name), username, password, and options. Always wrap it in tr...

Read answer →
3

What are prepared statements and why are they important?

Prepared statements separate SQL logic from data, so user input is never treated as executable SQL. This is th...

Read answer →
4

How do you handle transactions in PDO?

Transactions ensure a group of database operations either all succeed or all fail together, maintaining data c...

Read answer →
5

What is the difference between bindParam() and bindValue() in PDO?

AspectbindParam()bindValue()Binding typeBy referenceBy valueWhen value is readAt execute() timeImmediately whe...

Read answer →
6

How do you fetch data using PDO in different formats?

PDO supports several fetch styles controlled by PDO::FETCH_* constants.Fetch modeReturnsPDO::FETCH_ASSOCAssoci...

Read answer →
7

How does MySQLi handle prepared statements differently from PDO?

MySQLi uses positional placeholders (?) with a type string for binding, while PDO supports both positional and...

Read answer →
8

How do you prevent SQL injection in PHP database queries?

SQL injection happens when untrusted input is concatenated directly into a SQL query, letting attackers alter...

Read answer →
9

How do you handle database connection errors gracefully?

Set PDO to throw exceptions, catch them, log details for debugging, and show a generic message to users withou...

Read answer →
10

What is connection pooling and does PHP support it natively?

Connection pooling reuses a set of open database connections across requests instead of opening/closing one pe...

Read answer →