PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
How to get PHP to recognize a new class extended from MDB2?

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> PEAR
View previous topic :: View next topic  
Author Message
jonathanm



Joined: 06 Apr 2011
Posts: 4

PostPosted: Wed Apr 06, 2011 11:54 pm    Post subject: How to get PHP to recognize a new class extended from MDB2? Reply with quote

Hi, all.

I'm a total noob at PHP and PEAR. I'm running PHP 5.3.6 on Windows XP Pro.

I've written a new class, MDB2_Driver_pfusionsql that extends MDB2_Driver_Common. I placed it in its own file, pfusionsql.php, under PEAR/MDB2/Driver.

On my web page code, I invoke it by setting the DSN with
$dsn['phptype'] = 'pfusionsql';
and with other appropriate names/values. Then I use the MDB2::connect($dsn) method. That returns an error object with the following messages:

MDB2 Error: not found
unable to find package 'MDB2_Driver_pfusionsql' file 'MDB2\Driver\pfusionsql.php'

I don't know anything about building packages or anything like that. I just figured if I put the code under the right directory it would be recognized.

Can anyone tell me how to make PHP recognize this new code?
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1235

PostPosted: Thu Apr 07, 2011 12:23 am    Post subject: Reply with quote

Are you able to use any of the standard drivers, e.g. 'mysqli'? If not, then it's likely an issue with the include_path. The directory that contains MDB2.php and the MDB2 subdirectory needs to be contained in the include_path setting of PHP.
Back to top
View user's profile Send private message
jonathanm



Joined: 06 Apr 2011
Posts: 4

PostPosted: Thu Apr 07, 2011 12:28 am    Post subject: Reply with quote

Yes, the standard drivers (the only other one I'm using is mysql) work just fine. The mysql.php file that contains MDB2_Driver_mysql is in the same directory as my file, pfusionsql.php, which contains MDB2_Driver_pfusionsql.
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1235

PostPosted: Thu Apr 07, 2011 12:41 am    Post subject: Reply with quote

Hmm, the mentioned error message will be generated if both include_once() and MDB::fileExists() fail. The latter method checks each directory that is contained in the include_path setting. Therefore, it's likely an issue with the include_path. (The fact that 'mysql' works might be caused by something else, e.g. a very old MDB2 installation or a broken more current, maybe manual, MDB2 installation.)
Back to top
View user's profile Send private message
jonathanm



Joined: 06 Apr 2011
Posts: 4

PostPosted: Thu Apr 07, 2011 4:23 pm    Post subject: Reply with quote

I appreciate your help, Mark. I think you're right; it has to be a path (or maybe permissions?) issue. But I'm having trouble seeing the problem.

Here is the line from php.ini regarding the include_path:

Code:
include_path = ".;C:\Program Files\PHP\PEAR"


Here is the path to the file:

Quote:
C:\program files\PHP\PEAR\MDB2\Driver\pfusionsql.php


I've been going over the code in MDB2.php and I see the two points of failure you mentioned, but for the life of me I can't see why it's failing. The error message shows that it considers the value of $filename to be "MDB2\Driver\pfusionsql.php", and with the include_path being what it is, it should find it.

Hmmmm.
Back to top
View user's profile Send private message
jonathanm



Joined: 06 Apr 2011
Posts: 4

PostPosted: Thu Apr 07, 2011 5:26 pm    Post subject: Reply with quote

OK. Figured it out. Your posts lead me to dive deeper into the MDB2 code and I replicated some parts of that code in a test page. What was happening was the file was failing is_readable() due to permissions.

Thanks much for your help, Mark!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> PEAR All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement