Blog posts tagged "pear"

PEAR: No release with state equal to: ‘stable’ found for …

August 23rd, 2004

Trying to use:

pear install Some_Package 

but getting

No release with state equal to: 'stable' found for Some_Package?

Some people will tell you to try:

pear install -f Some_Package 

(i.e. force install) A better solution is:

pear remote-info Some_Package

You’ll see near the top the latest version, e.g. Lastest: 0.8RC3.

Then you can do:

pear install Some_Package-0.8RC3

Sometimes you’ll already have a package installed (e.g. "Package 'Foo_Package' is already installed"), but need to upgrade to a unstable version.

pear remote-info Foo_Package

Package details:
================
Latest      1.0.2
Installed   1.0.1
...

pear install -f Foo_Package-1.0.2

PEAR::DB and MySQL’s AUTO_INCREMENT Fields

January 31st, 2004

In which our protagonist begins a more thorough exploration of PEAR, and quickly runs into a challenge. Non-PHP hackers should feel free to avert their eyes. Maybe this is a well known hack, maybe (hopefully!) there is a better way to do this, but a quick Google search turned up a deafening silence, a marked dearth, of information on how to access a MySQL insert_id (the value created by inserting a row into a table with an AUTO_INCREMENT column).

I understand that using AUTO_INCREMENT columns is the “wrong” way to do things as far as PEAR is concerned, I’m supposed to use its implemented in PHP sequences, rather then the native and implemented in C method I’ve been using quite happily for years. (If I find myself migrating my MySQL app to Oracle sometime soon, I promise you AUTO_INCREMENT columns are going to be the least of my worries.)

Perl DBI faced a similar dilemma many years ago, and decided, wisely, to punt on the whole issue. They didn’t provide a solution, and they didn’t preclude you from using your native solution. Turns out sometimes doing less is more.

And lastly, when the hell did PHP get so high and holy that it refuses to let me code the way I want to code? Stuff like this constantly turns me off of PEAR, the whole thing just kind of has a bad smell about it.

But enough with the ranting, so here is my current, hold-me-over-until-someone-points-out-the-error-of-my-ways solution.

Your PEAR::DB object $dbh holds a reference to the MySQL connection object in $dbh->connection. Which allows you take a stroll down memory lane to the bad old days with this little gem:

$id = mysql_insert_id($dbh->connection)

For all our veneer of OO civilization, it doesn’t take much to scratch away the surface and expose our naked barbarian PHP soul does it?

Tagged: Uncategorized , , , ,