Jump to content
Larry Ullman's Book Forums

Recommended Posts

I got PEAR installed on my system. I'm working on Chapter 4, Authentication with Pear. Larry tells us to install Pear Auth package and also Pear DB.

 

The Pear website says Pear DB is deprecated in favor of Pear MDB2, so I installed this latter package.

 

However, when I ran login.php I got this warning

 

 


Fatal error: Class 'DB' not found in /Users/michaelmitchell/pear/share/pear/Auth/Container/DB.php on line 150

 

 

Anyone have any idea what's going on here?

 

 

This is the block of code referred to in the error message. The third line below starting

 if(!DB::....

is line 150 in the error message

  function _prepare()
   {
       if (!DB::isConnection($this->db)) {
           $res = $this->_connect($this->options['dsn']);
           if (DB::isError($res) || PEAR::isError($res)) {
               return $res;
           }
       }
       if ($this->options['auto_quote'] && $this->db->dsn['phptype'] != 'sqlite') {
           if (strpos('.', $this->options['table']) === false) {
               $this->options['final_table'] = $this->db->quoteIdentifier($this->options['table']);
           } else {
               $t = explode('.', $this->options['table']);
               for ($i = 0, $count = count($t); $i < $count; $i++)
                   $t[$i] = $this->db->quoteIdentifier($t[$i]);
               $this->options['final_table'] = implode('.', $t);
           }
           $this->options['final_usernamecol'] = $this->db->quoteIdentifier($this->options['usernamecol']);
           $this->options['final_passwordcol'] = $this->db->quoteIdentifier($this->options['passwordcol']);
       } else {
           $this->options['final_table'] = $this->options['table'];
           $this->options['final_usernamecol'] = $this->options['usernamecol'];
           $this->options['final_passwordcol'] = $this->options['passwordcol'];
       }
       return true;
   }

Link to comment
Share on other sites

Mike (*3), kudos for figuring it out and thanks for sharing the solution. I do believe that PEAR is failing to live up to its promise, and the Zend Framework may be a better alternative. It's easier to install, is kept updated, and can be used in pieces. I'll have to think about this when I go to do the third edition next year.

Link to comment
Share on other sites

It is a shame that PEAR seems quite tricky, because it seems to have some wonderful segments of code. I actually note the comment above, that Zend may be a better option. When I was having trouble with my PEAR installation I was inside the depths of XAMPP and saw quite a few folders for ZEND, so maybe it comes included with XAMPP..

 

*UPDATE - I've just had a quick Google and apparently it is installed on XAMPP, however i'm not sure about MAMP, i've looked for all MAC users though. I've see it has Zend Optimizer 3.3.9 and eAccelerator 0.9.6. Not really sure what this means in terms of Zend i'm afraid, but maybe it could be useful to some people. Particulary if your using XAMPP on windows as it's pre-packaged*

Link to comment
Share on other sites

 Share

×
×
  • Create New...