which connection is best?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I started with php and mysql and i discovered three methods for connecting
to a database:


$db = &ADONewConnection('mysql');
$db->Connect('localhost', 'root', 'pw', 'reserv');

$link = mysql_connect("localhost", "mysql_user", "mysql_password")
   or die("Impossible de se connecter : " . mysql_error());

Which one is the best and why?
What are the pro/contras for each?


Re: which connection is best?

Quoted text here. Click to load it

 ODBC. Used a lot on ASP, not so much in PHP, as PHP has native database
libraries (including MySQL).

Quoted text here. Click to load it

 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.

Quoted text here. Click to load it

 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.

Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

Re: which connection is best?

Andy Hassall wrote:

Quoted text here. Click to load it

I second this opion.
ADODB works just great. (But the documentation could use a little  
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.

Erwin Moller

Re: which connection is best?

Quoted text here. Click to load it

that is www.phplens.com/adodb

Re: which connection is best?

Thanks all

"Erwin Moller"  
Quoted text here. Click to load it

Site Timeline