php - Why should I make database wrapper? -
i'm wondering why should need database wrapper php. wrapper mysqli or pdo. it's class calls pdo/mysqli class. why should need it? advantages? try make 1 - don't main goal. why need it?? =]
abstractions pdo
intend make things more secure. database execution want "strongly typed" means prevented:
$mydangeroussql = "select * dba x ='"+$somevariable+"'";
the above result in called sql-injection.
when using pdo
explicitly "x of type string" or whatever type use in database. in way statement can "prepared" , cannot "inject" new sql-code it. makes more secure.
this 1 of reasons though, biggest one. , don't write own wrapper/abstraction if it's not learning purpose, there lot of ones out there already.
here post talking database abstraction in php.
Comments
Post a Comment