[PHP] Database Abstraction Class

2009-03-07 Thread Michael A. Peters
In some earlier thread (I really don't want to dig to find it) I argued 
for running mysql_real_escape_string right on the _POST


I must concede I was definitely wrong about that.

The right place to do it is in a database abstraction class that does 
the actual insert for you, so that if you need to move your app to a 
different DB backend you just need to add the proper support to your 
abstraction class for the new DB.


Let it take care of the escaping when it inserts.

Anywhoo, that being said, does anyone have a suggestion for a good 
database abstraction class?


Preferably one that already has decent support for several open source 
databases?


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



Re: [PHP] Database Abstraction Class

2009-03-07 Thread Richard Heyes
Hi,

 Anywhoo, that being said, does anyone have a suggestion for a good database
 abstraction class?

Ooh, I think you'll get the odd one or two...

 Preferably one that already has decent support for several open source
 databases?

PEAR::DB was good, but IIRC it's now been deprecated in favour of
MDB2. Which may or may not also be in PEAR.

-- 
Richard Heyes

HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari:
http://www.rgraph.net (Updated February 28th)

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



Re: [PHP] Database Abstraction Class

2009-03-07 Thread Michael A. Peters

Richard Heyes wrote:

Hi,


Anywhoo, that being said, does anyone have a suggestion for a good database
abstraction class?


Ooh, I think you'll get the odd one or two...


Preferably one that already has decent support for several open source
databases?


PEAR::DB was good, but IIRC it's now been deprecated in favour of
MDB2. Which may or may not also be in PEAR.



Thanks!
http://pear.php.net/package/MDB2

looks like what I'm looking for.
I'll give that one a try.

Never used pear before, but I seem to recall there being some issues 
where pear did not provide very good forward support when moving to new 
versions of php causing a need to recode. Is that still an issue?


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



Re: [PHP] Database Abstraction Class

2009-03-07 Thread Richard Heyes
Hi,

 Never used pear before, but I seem to recall there being some issues where
 pear did not provide very good forward support when moving to new versions
 of php causing a need to recode. Is that still an issue?

Don't really know. I've not really had a problem with the stuff that
I've written. I suppose it depends very much on each individual
package author (there are a fair few).

-- 
Richard Heyes

HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari:
http://www.rgraph.net (Updated February 28th)

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



Re: [PHP] Database Abstraction Class

2009-03-07 Thread Eric Butera
On Sat, Mar 7, 2009 at 8:04 AM, Michael A. Peters mpet...@mac.com wrote:
 In some earlier thread (I really don't want to dig to find it) I argued for
 running mysql_real_escape_string right on the _POST

 I must concede I was definitely wrong about that.

 The right place to do it is in a database abstraction class that does the
 actual insert for you, so that if you need to move your app to a different
 DB backend you just need to add the proper support to your abstraction class
 for the new DB.

 Let it take care of the escaping when it inserts.

 Anywhoo, that being said, does anyone have a suggestion for a good database
 abstraction class?

 Preferably one that already has decent support for several open source
 databases?

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



PDO.  :)  Anything else is a waste of cpu cycles.


-- 
http://www.voom.me | EFnet: #voom

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



Re: [PHP] Database Abstraction Class

2009-03-07 Thread Nitsan Bin-Nun
I'm personally using CI DB abstraction layer, also used zend_db, they both
good but as Eric said, I think PDO is a better option.

On Sat, Mar 7, 2009 at 7:34 PM, Eric Butera eric.but...@gmail.com wrote:

 On Sat, Mar 7, 2009 at 8:04 AM, Michael A. Peters mpet...@mac.com wrote:
  In some earlier thread (I really don't want to dig to find it) I argued
 for
  running mysql_real_escape_string right on the _POST
 
  I must concede I was definitely wrong about that.
 
  The right place to do it is in a database abstraction class that does the
  actual insert for you, so that if you need to move your app to a
 different
  DB backend you just need to add the proper support to your abstraction
 class
  for the new DB.
 
  Let it take care of the escaping when it inserts.
 
  Anywhoo, that being said, does anyone have a suggestion for a good
 database
  abstraction class?
 
  Preferably one that already has decent support for several open source
  databases?
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 

 PDO.  :)  Anything else is a waste of cpu cycles.


 --
 http://www.voom.me | EFnet: #voom

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




Re: [PHP] Database Abstraction Class

2009-03-07 Thread Paul M Foster
On Sat, Mar 07, 2009 at 12:34:40PM -0500, Eric Butera wrote:


snip

 
 PDO.  :)  Anything else is a waste of cpu cycles.

I've looked into PDO, and I just didn't find it as feature-rich as the
native (non-OO) function assortment for database types like MySQL and
PostgreSQL. Can PDO be extended?

In any case, I just wrote my own driver class for each DB type, and then
a function which instantiates the appropriate driver with the
appropriate parameters.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Database Abstraction Class

2009-03-07 Thread Eric Butera
On Sat, Mar 7, 2009 at 5:07 PM, Paul M Foster pa...@quillandmouse.com wrote:
 On Sat, Mar 07, 2009 at 12:34:40PM -0500, Eric Butera wrote:


 snip


 PDO.  :)  Anything else is a waste of cpu cycles.

 I've looked into PDO, and I just didn't find it as feature-rich as the
 native (non-OO) function assortment for database types like MySQL and
 PostgreSQL. Can PDO be extended?

 In any case, I just wrote my own driver class for each DB type, and then
 a function which instantiates the appropriate driver with the
 appropriate parameters.

 Paul

 --
 Paul M. Foster

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



Show me FETCH_INTO and FETCH_CLASS elsewhere. :D  What exactly is
missing for you?

-- 
http://www.voom.me | EFnet: #voom

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



Re: [PHP] Database Abstraction Class

2009-03-07 Thread Nathan Rixham

Eric Butera wrote:

On Sat, Mar 7, 2009 at 5:07 PM, Paul M Foster pa...@quillandmouse.com wrote:

On Sat, Mar 07, 2009 at 12:34:40PM -0500, Eric Butera wrote:


snip


PDO.  :)  Anything else is a waste of cpu cycles.

I've looked into PDO, and I just didn't find it as feature-rich as the
native (non-OO) function assortment for database types like MySQL and
PostgreSQL. Can PDO be extended?

In any case, I just wrote my own driver class for each DB type, and then
a function which instantiates the appropriate driver with the
appropriate parameters.

Paul

--
Paul M. Foster

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




Show me FETCH_INTO and FETCH_CLASS elsewhere. :D  What exactly is
missing for you?



try using those two with private variables using setters or magic 
methods to set and you'll see :p


nath

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



Re: [PHP] Database Abstraction Class

2009-03-07 Thread Eric Butera
On Sat, Mar 7, 2009 at 5:20 PM, Nathan Rixham nrix...@gmail.com wrote:
 Eric Butera wrote:

 On Sat, Mar 7, 2009 at 5:07 PM, Paul M Foster pa...@quillandmouse.com
 wrote:

 On Sat, Mar 07, 2009 at 12:34:40PM -0500, Eric Butera wrote:


 snip

 PDO.  :)  Anything else is a waste of cpu cycles.

 I've looked into PDO, and I just didn't find it as feature-rich as the
 native (non-OO) function assortment for database types like MySQL and
 PostgreSQL. Can PDO be extended?

 In any case, I just wrote my own driver class for each DB type, and then
 a function which instantiates the appropriate driver with the
 appropriate parameters.

 Paul

 --
 Paul M. Foster

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



 Show me FETCH_INTO and FETCH_CLASS elsewhere. :D  What exactly is
 missing for you?


 try using those two with private variables using setters or magic methods to
 set and you'll see :p

 nath


Don't have to worry about it if it's a value object.

-- 
http://www.voom.me | EFnet: #voom

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



Re: [PHP] Database Abstraction Class

2009-03-07 Thread Paul M Foster
On Sat, Mar 07, 2009 at 05:12:28PM -0500, Eric Butera wrote:

 On Sat, Mar 7, 2009 at 5:07 PM, Paul M Foster pa...@quillandmouse.com wrote:
  On Sat, Mar 07, 2009 at 12:34:40PM -0500, Eric Butera wrote:
 
 
  snip
 
 
  PDO.  :)  Anything else is a waste of cpu cycles.
 
  I've looked into PDO, and I just didn't find it as feature-rich as the
  native (non-OO) function assortment for database types like MySQL and
  PostgreSQL. Can PDO be extended?
 
  In any case, I just wrote my own driver class for each DB type, and then
  a function which instantiates the appropriate driver with the
  appropriate parameters.
 
  Paul
 
  --
  Paul M. Foster
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 Show me FETCH_INTO and FETCH_CLASS elsewhere. :D  What exactly is
 missing for you?

I take it back. My look was too cursory. I see most of the functions I
use there.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Database Abstraction Class

2009-03-07 Thread Lester Caine

( Sorry Eric - forgot to change the email address again :( )

Eric Butera wrote:

On Sat, Mar 7, 2009 at 8:04 AM, Michael A. Peters mpet...@mac.com wrote:

In some earlier thread (I really don't want to dig to find it) I argued for
running mysql_real_escape_string right on the _POST

I must concede I was definitely wrong about that.

The right place to do it is in a database abstraction class that does the
actual insert for you, so that if you need to move your app to a different
DB backend you just need to add the proper support to your abstraction class
for the new DB.

Let it take care of the escaping when it inserts.

Anywhoo, that being said, does anyone have a suggestion for a good database
abstraction class?

Preferably one that already has decent support for several open source
databases?

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


PDO.  :)  Anything else is a waste of cpu cycles.


But it only does data abstraction - not database abstraction ;)
ADOdb allows transparent SQL

--
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



[PHP] Database abstraction class

2003-01-20 Thread Clarkson, Nick

Hi,

Can anyone give me any pointers for creating a database abstraction class ?
I know there are a few out there already, but I'm doing this purely as an OO
learning exercise. I'm only at the paper design right now and I've only got
this far;

Properties:

Persistent  - Persistent connection ? (Boolean)
User- Username (String)
Pass- Password (String)
Host- Database Server (String)
Port- Database Port (3306 default for MySQL
Query   - Query to run (String)
Result  - Query Result (String)
Error   - Error returned (if any)
NumRows - Num of rows returned from query (int)
NumCols - Num od columns returned from query (int)
RowsPerPage - Number of rows per page
PagingOn- Return results in page ? (Boolean)
CurrentPage - Current page number (int)

Methods:

Connect - Connect to db
Close   - Close connection
SelectDB- Select database
RunQuery- Execute query
OutputTable - Output query results in table
OutputPage  - Outputs page of query results (calls OutputTable)
FetchRow- Returns single row from query
CreateLink  - Creates HTML A tags for drill down queries


Are there any other properties/methods that would be useful ? Links/advice
welcome (read needed)

Cheers,

Nick


This private and confidential e-mail has been sent to you by Egg.
The Egg group of companies includes Egg Banking plc
(registered no. 2999842), Egg Financial Products Ltd (registered
no. 3319027) and Egg Investments Ltd (registered no. 3403963) which
carries out investment business on behalf of Egg and is regulated
by the Financial Services Authority.  
Registered in England and Wales. Registered offices: 1 Waterhouse Square,
138-142 Holborn, London EC1N 2NA.
If you are not the intended recipient of this e-mail and have
received it in error, please notify the sender by replying with
'received in error' as the subject and then delete it from your
mailbox.


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