Home > Archive > PHP Pear > March 2005 > Re: [PEAR] isError crashes on use in DB package
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: [PEAR] isError crashes on use in DB package
|
|
| Arne de Bree 2005-03-30, 3:57 pm |
| Which DB package version you use?
http://pear.php.net/package/DB/download/ says the latest version depends
on php 4.2.0
Too bad Debian is so extreme slow updating their stable release to more
recent versions.=20
Gr,=20
Arne de Bree
> -----Oorspronkelijk bericht-----
> Van: brew@theMode.com [mailto:brew@theMode.com]
> Verzonden: woensdag 30 maart 2005 15:53
> Aan: PEAR general list
> Onderwerp: [PEAR] isError crashes on use in DB package
>=20
>=20
> I'm updating a website and plan to change it from mysql to postgresql=20
> and figure this is a good project to get my feet wet with the pear DB=20
> package. Formerly I'd used either the mysql or postgresl functions=20
> built into php.
>=20
> I played around with a simple pear DB script doing a SELECT on my=20
> development laptop and have it working, but when I put the same script
> on my production webserver it fails (but it occasionally runs a time=20
> or two and then starts failing again). Both machines run the stable=20
> version of Debian (Woody), namely:
>=20
> apache 1.3.26
> php 4.1.2
> postgresql 7.2.1
>=20
> The line in particular that is causing my script to fail is checking=20
> for errors on an object. Note that it's not failing on an error and=20
> executing the if statement, but rather executing isError seems to be=20
> causing the failure.
>=20
> if (PEAR::isError($db)) {
>=20
> or
>=20
> if (DB::isError($db)) {
>=20
>=20
> causes either a later error when I try to use the object in a query or
> I get (using lynx) 'Alert: Unexpected Network Read Error, connection=20
> aborted;' with no output to the browser.
>=20
> It's doesn't fail consistently, sometimes it runs, sometimes it=20
> crashes.
>=20
> Either one seems to work on my laptop. And if I comment out the error
> checking on the webserver script it runs fine, too.
> But, of course, I'd rather be checking for errors.
>=20
> I reloaded the php4 and the php4-pear packages on the webserver and=20
> restarted apache and still get the same failures.
>=20
> My questions are:
>=20
> Which of the two error checking statements above should I be using.=20
> Does it matter? I'd guess since the object is created in the DB=20
> package that DB::isError would be the one, but the pear docs show it=20
> both ways in various places.
>=20
> How can I get the error checking code not to fail on the web server?
>=20
> Should I just give up on pear and go back to the php functions?
>=20
> Thanks for any suggestions... I've added the script on the end of this
> email just in case I'm doing something dumb.....
>=20
> brew
>=20
> <?php
>=20
> require_once 'DB.php';
>=20
> $user =3D 'mode';
> $pass =3D 'xxxxxxxx';
> $host =3D '';
> $db_name =3D 'mode';
>=20
> // Data Source Name: This is the universal connection string $dsn =3D=20
> "pgsql://$user:$pass@$host/$db_name";
> $db =3D& DB::connect($dsn);
>=20
> # this seems to be the offending line!
> if (PEAR::isError($db)) {
> die ($db->getMessage());
> }
>=20
> $db->setFetchMode(DB_FETCHMODE_ASSOC);
>=20
> print <<<EOS
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> <html> <head>=20
> <title>Pear Test</title> </head> <body> <center> <h2> This is a Pear=20
> Test </h2> <table>
>=20
> EOS;
>=20
> $sql =3D "SELECT * from users ORDER BY user_id LIMIT 40"; $result =3D& =
> $db->query($sql);
>=20
> // Always check that $result is not an error # this seems to be=20
> another offending line!
> if (PEAR::isError($result)) {
> die ($result->getMessage());
> }
>=20
> // Get each row of data on each iteration while ($row =3D&
> $result->fetchRow()) {
> $id =3D $row['user_id'];
> $email_adr =3D $row['email_adr'];
> print "<tr><td>$id</td><td>$email_adr</td></tr> \n"; }
>=20
> // You can disconnect from the database with:
> $db->disconnect();
>=20
> ?>
>=20
> </table>
> </center>
> </body>
> </html>
>=20
>=20
> =20
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D[col
or=darkred]
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> Strange Brew (brew@theMode.com)
> Check out my Stock Option Covered Call website=20
> http://www.callpix.com
> and my Musician's Online Database Exchange http://www.TheMode.com[/color]
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D[col
or=darkred]
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>=20
> --
> PEAR General Mailing List (http://pear.php.net/) To=20
> unsubscribe, visit: http://www.php.net/unsub.php
>=20
>=20
>=20[/color]
| |
| Lee Braiden 2005-03-30, 3:57 pm |
| On Wednesday 30 Mar 2005 15:06, Arne de Bree wrote:
> Which DB package version you use?
>
> http://pear.php.net/package/DB/download/ says the latest version depends
> on php 4.2.0
>
> Too bad Debian is so extreme slow updating their stable release to more
> recent versions.
Debian stable doesn't change much, by definition. If you want something more
recent, use testing, or use apt pinning to import specific packages from
testing/unstable, or use apt-get.org to find backports to woody:
http://www1.apt-get.org/search.php?...&arch%5B%5D=all
--
Lee
| |
| brew@theMode.com 2005-03-30, 3:57 pm |
|
Lee and Arne.....
Not sure, but it's also the current version in Debian stable.
[color=darkred]
> Debian stable doesn't change much, by definition. If you want something
> more recent, use testing, or use apt pinning to import specific packages
> from testing/unstable, or use apt-get.org to find backports to woody:
I'm thinking of going to testing soon. I have four machines, maybe I'll
push one up to testing and play with it.
I'm guessing, though, that this might be a hardware problem one the main
production webserver, but everything else *seems* to be running fine.
Thanks...
brew
========================================
==================================
Strange Brew (brew@theMode.com)
Check out my Stock Option Covered Call website http://www.callpix.com
and my Musician's Online Database Exchange http://www.TheMode.com
========================================
==================================
| |
| Larry Garfield 2005-03-31, 3:58 am |
| brew@theMode.com wrote:
>
> I'm thinking of going to testing soon. I have four machines, maybe I'll
> push one up to testing and play with it.
Technically, I'd recommend switching to "sarge" rather than "testing".
For now they're the same thing but in the (hopefully) not too distant
future once sarge goes stable, it will get security updates while
testing will be drastically reorganized. For a production system, go
sarge and then wait a while before going back to testing. :-)
--
Larry Garfield AIM: LOLG42
larry@garfieldtech.com ICQ: 6817012
"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an
idea, which an individual may exclusively possess as long as he keeps it
to himself; but the moment it is divulged, it forces itself into the
possession of every one, and the receiver cannot dispossess himself of
it." -- Thomas Jefferson
|
|
|
|
|