|
Posted by Erwin Moller on 12/19/05 13:18
Andy Hassall wrote:
> On Sat, 17 Dec 2005 12:09:55 +0100, "Ben" <qsvqs@qsdcsqd> wrote:
>
>>I started with php and mysql and i discovered three methods for connecting
>>to a database:
>>
>>$conn="DRIVER={MySQL ODBC 3.51 DRIVER};SERVER=10.0.0.181;DATABASE=reserv";
>> $connect=odbc_connect($conn,'root','pw');
>
> ODBC. Used a lot on ASP, not so much in PHP, as PHP has native database
> libraries (including MySQL).
>
>>include('/inetpub/wwwroot/resphpaccess/adodb/adodb.inc.php');
>>$db = &ADONewConnection('mysql');
>>$db->Connect('localhost', 'root', 'pw', 'reserv');
>
> ADOdb database abstraction library (http://adodb.sourceforge.net), a thin
> PHP
> wrapper over the native functions.
>
> This is my favourite way of connecting to databases in PHP. It adds a
> consistent interface on top of the different native calls, and supports
> several databases (not just MySQL).
>
> Importantly for MySQL it emulates placeholders, which makes it easier to
> avoid
> SQL injection attacks.
>
> There is some overhead versus accessing MySQL with the native functions
> directly, but ADOdb fares well in benchmarks, particularly compared with
> other PHP database libraries.
>
>>$link = mysql_connect("localhost", "mysql_user", "mysql_password")
>> or die("Impossible de se connecter : " . mysql_error());
>
> Native MySQL library. The thinnest layer over MySQL, so presumably the
> fastest
> performance. You'll have to remember to do all your own data escaping,
> else you open yourself up to SQL injection attacks.
>
I second this opion.
ADODB works just great. (But the documentation could use a little
scrubbing.)
I started using ADODB to connect MSSQL to PHP which didn't work any other
way for me. (I was missing some modern version of some dll, so couldn't use
the native PHP mssql_* functions.)
Great package. Give it a shot.
I used it from here: www.php.lens.com/adodb
I am not sure which one is the most up-to-date. Probably sourceforge.
Regards,
Erwin Moller
Navigation:
[Reply to this message]
|