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;DATABASE=reserv";
$connect=odbc_connect($conn,'root','pw');
include('/inetpub/wwwroot/resphpaccess/adodb/adodb.inc.php');
$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?
Thanks
Ben 4 1776
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.
--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
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
Thanks all
"Erwin Moller"
<si******************************************@spam yourself.com> schreef in
bericht news:43***********************@news.xs4all.nl... I used it from here: www.php.lens.com/adodb
that is www.phplens.com/adodb This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ryan N. |
last post by:
Hello,
I saw a brief blurb on this somewhere and am unable to recall where...
In the context of Security, what are some best practices for
handling -storing, locating, retrieving- database OLEDB...
|
by: Mark |
last post by:
OK. Here we go. I have an ASP.NET application that does many hits to a SQL Server DB on a separate server. When I first created this application (2 years ago) and was very new to ASP/ASP.NET, to...
|
by: Balaji Kannan |
last post by:
Hi,
In dot net during component development i have used some
member variables in the class file. Inside the class i
have used the member declaration and the instant handling
in the following...
|
by: Jason MacKenzie |
last post by:
I'm looking at this application I've written and it seems kind of silly how
many times I open and close a connection to the database.
Is there a best practice as far as this is concerned? If I...
|
by: Jeff |
last post by:
For years I have been using VBA extensively for updating data to tables
after processing. By this I mean if I had to do some intensive processing
that resulted in data in temp tables, I would have...
|
by: fniles |
last post by:
I am using VB.NET 2003, SQL 2000, and SqlDataReader.
As I read data from tblA, I want to populate tblB. I use SQLDataReader for
both tables. I do not use thread.
When I ExecuteReader on tblB, I...
|
by: Mike P2 |
last post by:
Hi. I'm writing controls that have to query the database, and it
bothers me that I might have several of these controls on a page that
each create, open, and close their own connection with the...
|
by: pmclinn |
last post by:
When I'm connecting to Oracle or SQL I always wonder what is the best
way to close/dispose of a connection. I've been toying around with
creating a public shared class that has a connection string...
|
by: oaklander |
last post by:
What is the best way to connect to a database in Java Class?
I have used 3 different ways and would like to know what is the most efficient one.
1- Put the connection as a data member:
...
|
by: laziers |
last post by:
Hi there
Anybody knows what is the best way to manage creation 2000 of the
database connections at the same time?
Now Im doing it somethink like this:
using ( Connection conn =...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |