which connection is best?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ben

    which connection is best?

    Hi,

    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;DATA BASE=reserv";
    $connect=odbc_c onnect($conn,'r oot','pw');

    include('/inetpub/wwwroot/resphpaccess/adodb/adodb.inc.php') ;
    $db = &ADONewConnecti on('mysql');
    $db->Connect('local host', '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?

    Thanks
    Ben



  • Andy Hassall

    #2
    Re: which connection is best?

    On Sat, 17 Dec 2005 12:09:55 +0100, "Ben" <qsvqs@qsdcsq d> wrote:
    [color=blue]
    >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;DATA BASE=reserv";
    > $connect=odbc_c onnect($conn,'r oot','pw');[/color]

    ODBC. Used a lot on ASP, not so much in PHP, as PHP has native database
    libraries (including MySQL).
    [color=blue]
    >include('/inetpub/wwwroot/resphpaccess/adodb/adodb.inc.php') ;
    >$db = &ADONewConnecti on('mysql');
    >$db->Connect('local host', 'root', 'pw', 'reserv');[/color]

    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.
    [color=blue]
    >$link = mysql_connect(" localhost", "mysql_user ", "mysql_password ")
    > or die("Impossible de se connecter : " . mysql_error());[/color]

    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.u k :: http://www.andyh.co.uk
    http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

    Comment

    • Erwin Moller

      #3
      Re: which connection is best?

      Andy Hassall wrote:
      [color=blue]
      > On Sat, 17 Dec 2005 12:09:55 +0100, "Ben" <qsvqs@qsdcsq d> wrote:
      >[color=green]
      >>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;DATA BASE=reserv";
      >> $connect=odbc_c onnect($conn,'r oot','pw');[/color]
      >
      > ODBC. Used a lot on ASP, not so much in PHP, as PHP has native database
      > libraries (including MySQL).
      >[color=green]
      >>include('/inetpub/wwwroot/resphpaccess/adodb/adodb.inc.php') ;
      >>$db = &ADONewConnecti on('mysql');
      >>$db->Connect('local host', 'root', 'pw', 'reserv');[/color]
      >
      > 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.
      >[color=green]
      >>$link = mysql_connect(" localhost", "mysql_user ", "mysql_password ")
      >> or die("Impossible de se connecter : " . mysql_error());[/color]
      >
      > 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.
      >[/color]


      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

      Comment

      • Erwin Moller

        #4
        Re: which connection is best?

        > I used it from here: www.php.lens.com/adodb

        that is www.phplens.com/adodb

        Comment

        • Ben

          #5
          Re: which connection is best?

          Thanks all


          "Erwin Moller"
          <since_humans_r ead_this_I_am_s pammed_too_much @spamyourself.c om> schreef in
          bericht news:43a69789$0 $11080$e4fe514c @news.xs4all.nl ...[color=blue][color=green]
          >> I used it from here: www.php.lens.com/adodb[/color]
          >
          > that is www.phplens.com/adodb
          >[/color]


          Comment

          Working...