
August 10th, 2006, 04:54 PM
|
|
|
|
Join Date: Apr 2007
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
pear_db best practices
I think I'm finally going to bite the bullet and start using the pear_db class. However, as I've read the documentation, there is one thing that has been rubbing the wrong way. From the looks of it, If I want to access the database from inside a function or method, I really to declare the $db variable as GLOBAL. That seems very sloppy to me. There must be another way of doing this, especially with PHP5s new static keyword handling in classes.
What if, for example, I'm writing a class that I plan on distributing. I'm okay with assuming that the end user is using pear_db; that's something I could mark as a dependency on the download page. However, I don't want to assume that they store their database resource in the variable $db.
Can anybody offer any words of advice?
|