What is the difference between PDO and MySQLi prepared statements?

后端 未结 1 787
孤独总比滥情好
孤独总比滥情好 2021-02-11 02:58

What is the difference between these two prepared statements?

1

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

$         


        
1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-11 03:34

    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)
提交回复
热议问题