What is the difference between PDO and MySQLi prepared statements?

后端 未结 1 865
不知归路
不知归路 2021-02-11 03:28

What is the difference between these two prepared statements?

1

$stmt = $pdo->prepare(\'SELECT * FROM employees WHERE name = :name\');

$         


        
相关标签:
1条回答
  • 2021-02-11 03:39

    The difference is below:-

    1. Mysqli is only for the MySQL database. PDO supports other database using the same functions.

    2. Mysqli can be used in either an object-oriented style or a procedural style. PDO is always object-oriented.

    3. Mysqli supports prepared statements with ? placeholders for parameters. PDO supports both ? placeholders and also named placeholders, like :columnName.

    4. Mysqli requires that you use a function to bind each parameter value to the prepared statement. PDO also allows you to simply pass an array of parameter values as you execute the prepared statement.

    0 讨论(0)
提交回复
热议问题