开发者

PHP: should i bother learning MySQL extension or just learn PDO?

开发者 https://www.devze.com 2023-01-31 07:13 出处:网络
Since i found an information that PHP\'s MySQL extension has some potential security weaknesses and it\'s preety old, should i not bother with learning it and just check out PDO and MySQLi extension?

Since i found an information that PHP's MySQL extension has some potential security weaknesses and it's preety old, should i not bother with learning it and just check out PDO and MySQLi extension?

Is there any real difference between them?

Will learning all three give me benefit or is it enough to learn ju开发者_运维技巧st one, or two of them?

What do they differ from, except that one is procedural, and the other is OO (the 2nd and 3rd extension i mean).


MySQL and MySQLi act almost the exact same. I don't know that you can say "learn one over the other". Really, there isn't a problem with security with the standard MySQL extension as long as you know what you're doing; Mainly, using mysql_real_escape_string.

PDO is good, and I actually do recommend it though. Using prepared statements eliminates the need for using m_r_e_s().

All three extensions are not at all difficult to learn. The most difficult part (which is library independent), is learning SQL.


I would highly recommend using PDO in all new projects for maintainability reasons.

The easiest way to think about this is to turn the tables (I've been playing Phoenix Wright games again). If you're coming in as a maintenance programmer on a system that uses Postgres, would you rather have to learn the Postgres PHP extension, or just apply the PDO knowledge you already have?

0

精彩评论

暂无评论...
验证码 换一张
取 消