PDO MySQL: Use PDO::ATTR_EMULATE_PREPARES or not?

前端 未结 7 2097
南笙
南笙 2020-11-22 11:23

This is what I\'ve read so far about PDO::ATTR_EMULATE_PREPARES:

  1. PDO\'s prepare emulation is better for performance since MySQL\'s native prepare bypasses the
7条回答
  •  青春惊慌失措
    2020-11-22 11:44

    I would turn off emulate prepares as you're running 5.1 which means PDO will take advantage of the native prepared statement functionality.

    PDO_MYSQL will take advantage of native prepared statement support present in MySQL 4.1 and higher. If you're using an older version of the mysql client libraries, PDO will emulate them for you.

    http://php.net/manual/en/ref.pdo-mysql.php

    I ditched MySQLi for PDO for the prepared named statements and the better API.

    However, to be balanced, PDO performs negligibly slower than MySQLi, but it's something to bear in mind. I knew this when I made the choice, and decided that a better API and using the industry standard was more important than using a negligibly faster library that ties you to a particular engine. FWIW I think the PHP team is also looking favourably at PDO over MySQLi for the future too.

提交回复
热议问题