any reason *not* to use PEAR DB module when accessing mysql?

any reason *not* to use PEAR DB module when accessing mysql?

am 19.03.2010 15:17:22 von rpjday

(just a warning -- as a relative newbie to PHP, i'll probably have
the occasional dumb question. just humour me.)

i'm looking at some existing PHP code that accesses a mysql 5.0 db,
and it's coded using the mysql-specific calls: mysql_connect,
mysql_select_db, etc, etc.

is there any reason i *wouldn't* want to rewrite that code using the
more general PEAR DB module, and use mysqli? certainly, as i read it,
using the PEAR DB module would make it easier down the road if i
suddenly decide to change the DB backend.

anyway, any compelling arguments for or against?

rday
--


============================================================ ============
Robert P. J. Day Waterloo, Ontario, CANADA

Linux Consulting, Training and Kernel Pedantry.

Web page: http://crashcourse.ca
Twitter: http://twitter.com/rpjday
============================================================ ============

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: any reason *not* to use PEAR DB module when accessingmysql?

am 19.03.2010 15:23:30 von Ashley Sheridan

--=-5ukrGfk46sABZqAy7hMV
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Fri, 2010-03-19 at 10:17 -0400, Robert P. J. Day wrote:

> (just a warning -- as a relative newbie to PHP, i'll probably have
> the occasional dumb question. just humour me.)
>
> i'm looking at some existing PHP code that accesses a mysql 5.0 db,
> and it's coded using the mysql-specific calls: mysql_connect,
> mysql_select_db, etc, etc.
>
> is there any reason i *wouldn't* want to rewrite that code using the
> more general PEAR DB module, and use mysqli? certainly, as i read it,
> using the PEAR DB module would make it easier down the road if i
> suddenly decide to change the DB backend.
>
> anyway, any compelling arguments for or against?
>
> rday
> --
>
>
> ============================================================ ============
> Robert P. J. Day Waterloo, Ontario, CANADA
>
> Linux Consulting, Training and Kernel Pedantry.
>
> Web page: http://crashcourse.ca
> Twitter: http://twitter.com/rpjday
> ============================================================ ============
>


The only problem I can foresee is if the system you're looking to
replace the mysql calls in uses any specific mysql-only features and
functions. So, for example, not all database types support grabbing the
last inserted id (and grabbing the MAX(id) is just asking for trouble)

Have a look through the code to see if there any database calls that you
think might throw up any issues. I believe the Pear module supports all
the mysql functions, but there might be issues if you want to change the
back end at some point in the future.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-5ukrGfk46sABZqAy7hMV--

Re: any reason *not* to use PEAR DB module when accessing

am 19.03.2010 16:16:48 von Paul M Foster

On Fri, Mar 19, 2010 at 02:23:30PM +0000, Ashley Sheridan wrote:

> On Fri, 2010-03-19 at 10:17 -0400, Robert P. J. Day wrote:
>
> > (just a warning -- as a relative newbie to PHP, i'll probably have
> > the occasional dumb question. just humour me.)
> >
> > i'm looking at some existing PHP code that accesses a mysql 5.0 db,
> > and it's coded using the mysql-specific calls: mysql_connect,
> > mysql_select_db, etc, etc.
> >
> > is there any reason i *wouldn't* want to rewrite that code using the
> > more general PEAR DB module, and use mysqli? certainly, as i read it,
> > using the PEAR DB module would make it easier down the road if i
> > suddenly decide to change the DB backend.
> >
> > anyway, any compelling arguments for or against?
> >
> > rday
>
>
> The only problem I can foresee is if the system you're looking to
> replace the mysql calls in uses any specific mysql-only features and
> functions. So, for example, not all database types support grabbing the
> last inserted id (and grabbing the MAX(id) is just asking for trouble)
>
> Have a look through the code to see if there any database calls that you
> think might throw up any issues. I believe the Pear module supports all
> the mysql functions, but there might be issues if you want to change the
> back end at some point in the future.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>

I would suggest instead the built-in PDO module for PHP. This is
generic, and suitable for several DBMS back-ends. But any direct queries
using features unique to a specific DBMS (like Ash's "last inserted id")
will have to be coded specifically for your back-end.

Paul

--
Paul M. Foster

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: any reason *not* to use PEAR DB module when accessing

am 19.03.2010 16:17:47 von Adam Richardson

--00163600cdaba10758048228d93c
Content-Type: text/plain; charset=ISO-8859-1

On Fri, Mar 19, 2010 at 10:23 AM, Ashley Sheridan
wrote:

> On Fri, 2010-03-19 at 10:17 -0400, Robert P. J. Day wrote:
>
> > (just a warning -- as a relative newbie to PHP, i'll probably have
> > the occasional dumb question. just humour me.)
> >
> > i'm looking at some existing PHP code that accesses a mysql 5.0 db,
> > and it's coded using the mysql-specific calls: mysql_connect,
> > mysql_select_db, etc, etc.
> >
> > is there any reason i *wouldn't* want to rewrite that code using the
> > more general PEAR DB module, and use mysqli? certainly, as i read it,
> > using the PEAR DB module would make it easier down the road if i
> > suddenly decide to change the DB backend.
> >
> > anyway, any compelling arguments for or against?
> >
> > rday
> > --
> >
> >
> > ============================================================ ============
> > Robert P. J. Day Waterloo, Ontario, CANADA
> >
> > Linux Consulting, Training and Kernel Pedantry.
> >
> > Web page: http://crashcourse.ca
> > Twitter: http://twitter.com/rpjday
> > ============================================================ ============
> >
>
>
> The only problem I can foresee is if the system you're looking to
> replace the mysql calls in uses any specific mysql-only features and
> functions. So, for example, not all database types support grabbing the
> last inserted id (and grabbing the MAX(id) is just asking for trouble)
>
> Have a look through the code to see if there any database calls that you
> think might throw up any issues. I believe the Pear module supports all
> the mysql functions, but there might be issues if you want to change the
> back end at some point in the future.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
You also might prefer the level of abstraction and simplicity provided by
PDO (note that it's a data access abstraction layer, not a database
abstraction layer, http://www.php.net/manual/en/intro.pdo.php.)

Adam

--
Nephtali: PHP web framework that functions beautifully
http://nephtaliproject.com

--00163600cdaba10758048228d93c--

Re: any reason *not* to use PEAR DB module when accessing

am 19.03.2010 16:21:40 von Rene Veerman

another option: adodb.sf.net.

and yep, i'm fully for using a db abstraction layer.


On Fri, Mar 19, 2010 at 3:17 PM, Robert P. J. Day w=
rote:
>
> =A0(just a warning -- as a relative newbie to PHP, i'll probably have
> the occasional dumb question. =A0just humour me.)
>
> =A0i'm looking at some existing PHP code that accesses a mysql 5.0 db,
> and it's coded using the mysql-specific calls: =A0mysql_connect,
> mysql_select_db, etc, etc.
>
> =A0is there any reason i *wouldn't* want to rewrite that code using the
> more general PEAR DB module, and use mysqli? =A0certainly, as i read it,
> using the PEAR DB module would make it easier down the road if i
> suddenly decide to change the DB backend.
>
> =A0anyway, any compelling arguments for or against?
>
> rday
> --
>
>
> ==================== =====
==================== =====3D=
==================== ===3D
> Robert P. J. Day =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 Waterloo, Ontario, CANADA
>
> =A0 =A0 =A0 =A0 =A0 =A0Linux Consulting, Training and Kernel Pedantry.
>
> Web page: =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 =A0http://crashcourse.ca
> Twitter: =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 http://twitter.com/rpjday
> ==================== =====
==================== =====3D=
==================== ===3D
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: any reason *not* to use PEAR DB module when accessing mysql?

am 19.03.2010 17:10:11 von Nilesh Govindrajan

On 03/19/2010 08:51 PM, Rene Veerman wrote:
> another option: adodb.sf.net.
>
> and yep, i'm fully for using a db abstraction layer.
>
>
> On Fri, Mar 19, 2010 at 3:17 PM, Robert P. J. Day wrote:
>>
>> (just a warning -- as a relative newbie to PHP, i'll probably have
>> the occasional dumb question. just humour me.)
>>
>> i'm looking at some existing PHP code that accesses a mysql 5.0 db,
>> and it's coded using the mysql-specific calls: mysql_connect,
>> mysql_select_db, etc, etc.
>>
>> is there any reason i *wouldn't* want to rewrite that code using the
>> more general PEAR DB module, and use mysqli? certainly, as i read it,
>> using the PEAR DB module would make it easier down the road if i
>> suddenly decide to change the DB backend.
>>
>> anyway, any compelling arguments for or against?
>>
>> rday
>> --
>>
>>
>> ============================================================ ============
>> Robert P. J. Day Waterloo, Ontario, CANADA
>>
>> Linux Consulting, Training and Kernel Pedantry.
>>
>> Web page: http://crashcourse.ca
>> Twitter: http://twitter.com/rpjday
>> ============================================================ ============
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>

Adodb is the same one that is available in Visual Basic.

I suggest PDO. Easy to use and portable.

--
Nilesh Govindarajan
Site & Server Administrator
www.itech7.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: any reason *not* to use PEAR DB module when accessing mysql?

am 19.03.2010 17:18:31 von Larry Garfield

Add me to the list of people recommending PDO. It's much nicer to work
with than the ext/mysql API, and frankly more secure since you get
prepared statements. It won't get you complete database independence
for a number of reasons (mostly due to databases being too
unstandardized because they all suck in different ways; I say this as
someone who has written an abstraction layer atop PDO and it wasn't
easy), but it will get you part way there and even if you only ever use
MySQL is a nicer API to work with.

--Larry Garfield

On 3/19/10 9:17 AM, Robert P. J. Day wrote:
>
> (just a warning -- as a relative newbie to PHP, i'll probably have
> the occasional dumb question. just humour me.)
>
> i'm looking at some existing PHP code that accesses a mysql 5.0 db,
> and it's coded using the mysql-specific calls: mysql_connect,
> mysql_select_db, etc, etc.
>
> is there any reason i *wouldn't* want to rewrite that code using the
> more general PEAR DB module, and use mysqli? certainly, as i read it,
> using the PEAR DB module would make it easier down the road if i
> suddenly decide to change the DB backend.
>
> anyway, any compelling arguments for or against?
>
> rday
> --
>
>
> ============================================================ ============
> Robert P. J. Day Waterloo, Ontario, CANADA
>
> Linux Consulting, Training and Kernel Pedantry.
>
> Web page: http://crashcourse.ca
> Twitter: http://twitter.com/rpjday
> ============================================================ ============
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: any reason *not* to use PEAR DB module when accessing mysql?

am 19.03.2010 17:51:27 von Mattias Thorslund

Robert P. J. Day wrote:
> (just a warning -- as a relative newbie to PHP, i'll probably have
> the occasional dumb question. just humour me.)
>
> i'm looking at some existing PHP code that accesses a mysql 5.0 db,
> and it's coded using the mysql-specific calls: mysql_connect,
> mysql_select_db, etc, etc.
>
> is there any reason i *wouldn't* want to rewrite that code using the
> more general PEAR DB module, and use mysqli? certainly, as i read it,
> using the PEAR DB module would make it easier down the road if i
> suddenly decide to change the DB backend.
>
> anyway, any compelling arguments for or against?
>
> rday
> --
>

Well, the reason you shouldn't use PEAR DB in a new project is that it's
being deprecated. MDB2 is the PEAR successor, and does provide emulation
for some features that don't exist on all database platforms, such as
LastInsertID. It can also help you convert your database from one
platform to another, since it also provides methods for detecting and
managing the database structure itself (the Manager and Reverse modules).

That said, if I were to start a new project at this time, I would look
closer at whether PDO fits my needs.

Cheers,

Mattias

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: any reason *not* to use PEAR DB module when accessing mysql?

am 19.03.2010 18:11:15 von Lester Caine

larry@garfieldtech.com wrote:
> Add me to the list of people recommending PDO. It's much nicer to work
> with than the ext/mysql API, and frankly more secure since you get
> prepared statements. It won't get you complete database independence for
> a number of reasons (mostly due to databases being too unstandardized
> because they all suck in different ways; I say this as someone who has
> written an abstraction layer atop PDO and it wasn't easy), but it will
> get you part way there and even if you only ever use MySQL is a nicer
> API to work with.

Of cause ADODB will actually use PDO for those databases that are currently
available in it, and the generic drivers for those which are not currently
supported by PDO ;) One can also check performance by switching between PDO
driver and generic if you want to ...

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: any reason *not* to use PEAR DB module when accessingmysql?

am 19.03.2010 18:33:13 von rpjday

On Fri, 19 Mar 2010, Mattias Thorslund wrote:

> Robert P. J. Day wrote:
> > (just a warning -- as a relative newbie to PHP, i'll probably have
> > the occasional dumb question. just humour me.)
> >
> > i'm looking at some existing PHP code that accesses a mysql 5.0 db,
> > and it's coded using the mysql-specific calls: mysql_connect,
> > mysql_select_db, etc, etc.
> >
> > is there any reason i *wouldn't* want to rewrite that code using the
> > more general PEAR DB module, and use mysqli? certainly, as i read it,
> > using the PEAR DB module would make it easier down the road if i
> > suddenly decide to change the DB backend.
> >
> > anyway, any compelling arguments for or against?
> >
> > rday
> > --
> >
>
> Well, the reason you shouldn't use PEAR DB in a new project is that
> it's being deprecated. MDB2 is the PEAR successor, ...

you're right and, in fact, i knew that, i just forgot. i'm also
taking seriously the recommendations for PDO and adodb.

rday
--


============================================================ ============
Robert P. J. Day Waterloo, Ontario, CANADA

Linux Consulting, Training and Kernel Pedantry.

Web page: http://crashcourse.ca
Twitter: http://twitter.com/rpjday
============================================================ ============

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: any reason *not* to use PEAR DB module when accessing mysql?

am 19.03.2010 22:01:03 von Michael Peters

Mattias Thorslund wrote:
> Robert P. J. Day wrote:
>> (just a warning -- as a relative newbie to PHP, i'll probably have
>> the occasional dumb question. just humour me.)
>>
>> i'm looking at some existing PHP code that accesses a mysql 5.0 db,
>> and it's coded using the mysql-specific calls: mysql_connect,
>> mysql_select_db, etc, etc.
>>
>> is there any reason i *wouldn't* want to rewrite that code using the
>> more general PEAR DB module, and use mysqli? certainly, as i read it,
>> using the PEAR DB module would make it easier down the road if i
>> suddenly decide to change the DB backend.
>>
>> anyway, any compelling arguments for or against?
>>
>> rday
>> --
>>
>
> Well, the reason you shouldn't use PEAR DB in a new project is that it's
> being deprecated. MDB2 is the PEAR successor, and does provide emulation
> for some features that don't exist on all database platforms, such as
> LastInsertID. It can also help you convert your database from one
> platform to another, since it also provides methods for detecting and
> managing the database structure itself (the Manager and Reverse modules).
>
> That said, if I were to start a new project at this time, I would look
> closer at whether PDO fits my needs.

I use MDB2.
I hear PDO hyped a lot, what does it really give me that MDB2 does not,
other than making the application dependent upon a binary module?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: any reason *not* to use PEAR DB module when accessing

am 20.03.2010 08:05:23 von Paul M Foster

On Fri, Mar 19, 2010 at 02:01:03PM -0700, Michael A. Peters wrote:



>
> I use MDB2.
> I hear PDO hyped a lot, what does it really give me that MDB2 does not,
> other than making the application dependent upon a binary module?

Maybe nothing. But PDO is built-in and MDB2 isn't.

Paul

--
Paul M. Foster

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php