php - Preventing SQL injection with PDO or MySQLi -
i have read following post, , have questions: how can prevent sql injection in php?
i see can choose between pdo , mysqli. there difference, , how choose between them?
in example code use :name
pdo queries , ?
mysqli. shall replace with? php variable?
finally, how prepare begin using pdo on website? there thing need install or add, or can begin, , use same code provided in examples?
thank you
go pdo, you'll glad did.
back in ancient times of php 5.0, mysqli part of php, pdo had installed separately pecl.
since php 5.1, pdo has been part of standard php extensions. both should available on modern php installation. i've heard of few hosting companies still don't enable pdo, imho indicates hosting provider isn't keeping modern software, , it's reason switch different hosting provider, not reason use mysqli.
pdo has object-oriented usage, whereas mysqli supports both procedural , object-oriented usage.
pdo supports multiple drivers different brands of rdbms, whereas mysqli of course mysql.
there few cases writing code in pdo simpler. example if you're coding general-purpose function insert table, variable number of columns, it's easier pass array of parameters prepared statement pdo gymnastics have mysqli.
Comments
Post a Comment