PEAR newbie trying to user PEAR DB and falling at the first hurdle
PEAR newbie trying to user PEAR DB and falling at the first hurdle
am 03.12.2007 05:08:59 von bizt
Hi,
Ive just installed PEAR on my local machine and all is well, updated
the include_path to point to my PEAR dir. So, when I just try to make
a simple connection like so the script just seems to stop but no error
messsages. I do get error messages normally (ie. when I can a method
from an object that doesnt actually exist) as I have set
display_errors = On in php.ini.
Anyway, heres my code:
include('PEAR/DB/DB.php');
$dsn = "mysqli://root:password@localhost/testdb";
$conn = DB::connect($dsn);
if (DB::isError($conn)) {
print("Unable to connect to DB!!");
die($conn->getMessage());
}
?>
Btw Im using MySQL 5 so I understand that the prefix above in the DSN
should be 'mysqli'. My script just stops at theline ..
$conn = DB::connect($dsn);
... with no error messages or any indicated that there was a problem
until I place a ..
print 'Hello world!';
... after it to see where the script ends - nothing is printed. Any
ideas why this might be or how to gather some more information? Thanks
Burnsy
Re: PEAR newbie trying to user PEAR DB and falling at the first
am 03.12.2007 15:44:33 von Acrobatic
Burnsy,
I use Pear DB too, and it works great. The only differences between
your script and mine are the dsn connection, I use "mysql" instead of
"mysqli," so try that first. Then check your connection string if that
doesn't work. I break mine down into an array because it's a little
clearer, ie:
---------------
$dsn = array(
'phptype' => 'mysql',
'hostspec' => 'localhost',
'database' => 'testdb',
'username' => 'root',
'password' => 'password'
);
$conn = DB::connect($myDSN);
---------------
See if that helps...
On Dec 2, 10:08 pm, bizt wrote:
> Hi,
>
> Ive just installed PEAR on my local machine and all is well, updated
> the include_path to point to my PEAR dir. So, when I just try to make
> a simple connection like so the script just seems to stop but no error
> messsages. I do get error messages normally (ie. when I can a method
> from an object that doesnt actually exist) as I have set
> display_errors = On in php.ini.
>
> Anyway, heres my code:
>
>
>
> include('PEAR/DB/DB.php');
>
> $dsn = "mysqli://root:password@localhost/testdb";
> $conn = DB::connect($dsn);
>
> if (DB::isError($conn)) {
> print("Unable to connect to DB!!");
> die($conn->getMessage());
>
> }
>
> ?>
>
> Btw Im using MySQL 5 so I understand that the prefix above in the DSN
> should be 'mysqli'. My script just stops at theline ..
>
> $conn = DB::connect($dsn);
>
> .. with no error messages or any indicated that there was a problem
> until I place a ..
>
> print 'Hello world!';
>
> .. after it to see where the script ends - nothing is printed. Any
> ideas why this might be or how to gather some more information? Thanks
>
> Burnsy
Re: PEAR newbie trying to user PEAR DB and falling at the first
am 03.12.2007 15:53:10 von Acrobatic
Typo fix on my previous post:
$conn = DB::connect($dsn);
instead of ($myDSN)
>
> $conn = DB::connect($myDSN);
>
Re: PEAR newbie trying to user PEAR DB and falling at the first
am 04.12.2007 00:06:21 von bizt
On 3 Dec, 14:53, Acrobatic wrote:
> Typo fix on my previous post:
>
> $conn = DB::connect($dsn);
>
> instead of ($myDSN)
>
>
>
> > $conn = DB::connect($myDSN);
I tried your suggestion but still no luck. I thought Id go inside the
DB class and investigate and inside the connect function at the line
'@include_once "DB/${type}.php";' is where it seems to be falling
(code below). The string seems to be getting set right but my guess is
the @ character but im not too familair with what this does.
function &connect($dsn, $options = array())
{
$dsninfo = DB::parseDSN($dsn);
$type = $dsninfo['phptype'];
if (!is_array($options)) {
/*
* For backwards compatibility. $options used to be
boolean,
* indicating whether the connection should be persistent.
*/
$options = array('persistent' => $options);
}
if (isset($options['debug']) && $options['debug'] >= 2) {
// expose php errors with sufficient debug level
include_once "DB/${type}.php";
} else {
@include_once "DB/${type}.php";
}
..
..
..
Any ideas? Thanks Burnsy
Re: PEAR newbie trying to user PEAR DB and falling at the first hurdle
am 04.12.2007 03:13:28 von oliver.graetz
bizt schrieb:
> Ive just installed PEAR on my local machine and all is well, updated
> the include_path to point to my PEAR dir.
>
> include('PEAR/DB/DB.php');
Trying to keep you from having to throw much of your code away in a few
months I dare to ask if you voluntarily started using PEAR DB as opposed
to being forced to use it because you are trying to work with old code.
This is because the package is marked as
"This package has been superseded, but is still maintained for bugs and
security fixes. Use MDB2 instead."
(to clear this up: PEAR DB has been out of development for 21 straight
months before someone started fixing very old errors just to "maintain"
the package for old users that use it in their old apps)
You should not start learning to use something for which the developer
himself tells you to better not use it but something else instead. I'm
not saying "don't use it" myself but the "just installed" and "first
hurdle" set off some alarm bells...
OLLi
--
Dargo: "Does Moya know where we are?"
Pilot: "Yes, of course: We are someplace else. -- I'll get back to you
on the specifics."
[FarScape 101]
Re: PEAR newbie trying to user PEAR DB and falling at the firsthurdle
am 04.12.2007 10:27:02 von Adam Harvey
On Tue, 04 Dec 2007 03:13:28 +0100, Oliver Grätz wrote:
> "This package has been superseded, but is still maintained for bugs and
> security fixes. Use MDB2 instead."
More specifically (and I can't put this on pear.php.net at present
because pearweb doesn't yet support free text in that field), DB's only
going to be maintained until next August. The (fairly brief) mailing list
discussion confirming that is at
, for anyone
who's morbidly curious.
Adam
--
To e-mail: don't make an example out of me!
Re: PEAR newbie trying to user PEAR DB and falling at the first
am 04.12.2007 23:31:14 von Acrobatic
>
> "This package has been superseded, but is still maintained for bugs and
> security fixes. Use MDB2 instead."
That's news to me too--I use Pear DB in several projects so I'm pretty
familiar with it. Based on that I would also recommend jumping to MDB2
or something "more supported" because there's really no sense in
learning the other if it's not going to be supported much longer. I'll
start looking into alternatives myself.
Based on where your code is failing, I'd guess some sort of PATH
issue, maybe make sure your PEAR folders are all there (check for the
DB folder?).
Good luck
Re: PEAR newbie trying to user PEAR DB and falling at the first hurdle
am 05.12.2007 06:49:12 von AnrDaemon
Greetings, bizt.
In reply to Your message dated Monday, December 3, 2007, 07:08:59,
> Hi,
> Ive just installed PEAR on my local machine and all is well, updated
> the include_path to point to my PEAR dir. So, when I just try to make
> a simple connection like so the script just seems to stop but no error
> messsages. I do get error messages normally (ie. when I can a method
> from an object that doesnt actually exist) as I have set
> display_errors = On in php.ini.
> Anyway, heres my code:
>
And here is your error:
> include('PEAR/DB/DB.php');
It *SHOULD* be simple
include('DB.php');
if you have PEAR installed right. Otherwise PEAR::DB can't find and load it's
connectors and fails immediately at DB::connect().
> Btw Im using MySQL 5 so I understand that the prefix above in the DSN
> should be 'mysqli'.
You understand it wrong. Go to MySQL website and study the difference between
mysql and mysqli extensions. It is not a PHP related discussion.
> My script just stops at theline ..
> $conn = DB::connect($dsn);
As expected - PEAR::DB can't load proper connector.
--
Sincerely Yours, AnrDaemon
Re: PEAR newbie trying to user PEAR DB and falling at the first hurdle
am 05.12.2007 13:07:38 von Jerry Stuckle
AnrDaemon wrote:
> Greetings, bizt.
> In reply to Your message dated Monday, December 3, 2007, 07:08:59,
>
>> Hi,
>
>> Ive just installed PEAR on my local machine and all is well, updated
>> the include_path to point to my PEAR dir. So, when I just try to make
>> a simple connection like so the script just seems to stop but no error
>> messsages. I do get error messages normally (ie. when I can a method
>> from an object that doesnt actually exist) as I have set
>> display_errors = On in php.ini.
>
>> Anyway, heres my code:
>
>>
>
> And here is your error:
>
>> include('PEAR/DB/DB.php');
>
> It *SHOULD* be simple
>
> include('DB.php');
>
> if you have PEAR installed right. Otherwise PEAR::DB can't find and load it's
> connectors and fails immediately at DB::connect().
>
>> Btw Im using MySQL 5 so I understand that the prefix above in the DSN
>> should be 'mysqli'.
>
> You understand it wrong. Go to MySQL website and study the difference between
> mysql and mysqli extensions. It is not a PHP related discussion.
>
Actually, it is. mysql and mysqli are two different ways of accessing
MySQL from PHP. mysql is the functional interface and mysqli is the OO
interface.
>> My script just stops at theline ..
>
>> $conn = DB::connect($dsn);
>
> As expected - PEAR::DB can't load proper connector.
>
>
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: PEAR newbie trying to user PEAR DB and falling at the first hurdle
am 05.12.2007 16:35:55 von AnrDaemon
Greetings, Jerry Stuckle.
In reply to Your message dated Wednesday, December 5, 2007, 15:07:38,
>>> Btw Im using MySQL 5 so I understand that the prefix above in the DSN
>>> should be 'mysqli'.
>>
>> You understand it wrong. Go to MySQL website and study the difference between
>> mysql and mysqli extensions. It is not a PHP related discussion.
>>
> Actually, it is. mysql and mysqli are two different ways of accessing
> MySQL from PHP. mysql is the functional interface and mysqli is the OO
> interface.
Ok, I was wrong, forgive me.
While mysql and mysqli is two interfaces available to access MySQL5 database,
what to use is a whole programmer's choice. /me prefer mysql in case of
compatibility.
But is was never close to a case of problem of original poster.
--
Sincerely Yours, AnrDaemon
Re: PEAR newbie trying to user PEAR DB and falling at the first
am 07.12.2007 15:46:42 von bizt
On 4 Dec, 02:13, Oliver Grätz wrote:
> bizt schrieb:
>
> > Ive just installed PEAR on my local machine and all is well, updated
> > the include_path to point to my PEAR dir.
>
> > include('PEAR/DB/DB.php');
>
> Trying to keep you from having to throw much of your code away in a few
> months I dare to ask if you voluntarily started using PEAR DB as opposed
> to being forced to use it because you are trying to work with old code.
> This is because the package is marked as
>
> "This package has been superseded, but is still maintained for bugs and
> security fixes. Use MDB2 instead."
>
> (to clear this up: PEAR DB has been out of development for 21 straight
> months before someone started fixing very old errors just to "maintain"
> the package for old users that use it in their old apps)
>
> You should not start learning to use something for which the developer
> himself tells you to better not use it but something else instead. I'm
> not saying "don't use it" myself but the "just installed" and "first
> hurdle" set off some alarm bells...
>
> OLLi
>
> --
> Dargo: "Does Moya know where we are?"
> Pilot: "Yes, of course: We are someplace else. -- I'll get back to you
> on the specifics."
> [FarScape 101]
The reason im using PEAR DB is because Im currently going through a
book (Professional PHP) and it has part of a chapter devoted to this
class set so i thought id check it out. Im happy enough to build my
own data abstraction layer classes but want to ive this one a go. Ill
have a look at the MDB2 set.
Re: PEAR newbie trying to user PEAR DB and falling at the first hurdle
am 07.12.2007 16:28:38 von oliver.graetz
bizt schrieb:
> The reason im using PEAR DB is because Im currently going through a
> book (Professional PHP) and it has part of a chapter devoted to this
> class set so i thought id check it out. Im happy enough to build my
> own data abstraction layer classes but want to ive this one a go. Ill
> have a look at the MDB2 set.
One thing I've learnt: Don't buy any books on programming that deal with
a certain version of a language. Once you get them they're already
outdated. The PHP online documentation is killer! Use it! If you want to
buy books about programming then buy books about universal concepts like
"Programming Patterns". The information you get from such books NEVER
get old.
OLLi
--
Piper: "See what I mean? We have bigger naked breasts to worry about."
Phoebe: "Paige has her naked breasts to worry about. I've got yours."
[Charmed 702]