When building application that need coonections to databases, there are two common options. First, to use a programming language's build in feature to access the database. Second, using a wrapper class / library to provide an easy way to connect to the database.
In PHP, a build in feature to connect to databases is available. Take a look at PHP connection to MySQL. In PHP 5, there are two way to connect to MySQL, either using mysql_ command set, or using mysqli_ command set. Both of those command are incompatible. Example, to escape a string, mysql command set had the command and parameter like this format:
string mysql_real_escape_string ( string unescaped_string [, resource link_identifier] );
But, mysqli had the parameter position swapped:
string mysqli_real_escape_string ( mysqli link, string escapestr )
See, you can't savely replace each
mysql_
with mysqli_
, both command is not compatible. To connect to other database?? Every database build in command had it's own parameter sets, and it's non compatible with the other's command.The second way to access database was created to overcome those issues. One of the library that has multiple database connection support is ADODB. When using ADODB, the command to execute query in the MySQL and in the MSSQL is the same command. The parameter are in the same order. ADODB's version to above escape_string functions is
$conn->qstr(string);
ADODB wil take care resource identifier passing to actual command. ADODB wraps all needed variables into a single object. ADODB make PHP Programming easier.
0 komentar:
Posting Komentar