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 
MDB2 and socket

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



Joined: 07 Feb 2007
Posts: 6

PostPosted: Thu Mar 01, 2007 4:08 am    Post subject: MDB2 and socket Reply with quote

I'm slowly moving from DB to MDB2... I'd like to take advantage of the Unix domain socket for connecting to MySQL. First, do I need to specify the socket path (/tmp/mysql.sock), or does PEAR MDB2 override 'localhost' and try to connect to the local socket on its own, as does mysql_connect <http://www.php.net/function.mysql-connect>?

Second, if the socket path must be specified, then I am a bit confused about the exact syntax I need to use. For example, this $dsn works for PEAR DB, but not for MDB2 (which returns the error: MDB2 Error: Array)

Code:
$dsn = 'mysql://username:password@/tmp/mysql.sock/database';


What is the correct way to indicate the socket path?

Thanks, pw
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 998

PostPosted: Thu Mar 01, 2007 11:14 am    Post subject: Reply with quote

Example 34-1:
http://pear.php.net/manual/en/package.database.mdb2.intro-dsn.php

Or use the array notation for the DSN.
Back to top
View user's profile Send private message
pweil



Joined: 07 Feb 2007
Posts: 6

PostPosted: Thu Mar 01, 2007 7:53 pm    Post subject: Reply with quote

mark wrote:
Example 34-1:
http://pear.php.net/manual/en/package.database.mdb2.intro-dsn.php

Or use the array notation for the DSN.


Ok, thanks. Just for the record, I did look at the manual quite a bit before posting, but I guess I'm just a little dense (that happens to me with manuals for some reason). I went back at it this this morning and was able to get it to work.

And I take it from your reply that PEAR does indeed require you to specify a socket, unlike mysql_connect. I hope that the rest of my adjusting to MDB2 isn't as disorienting as this has been. Embarassed
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 998

PostPosted: Thu Mar 01, 2007 9:34 pm    Post subject: Reply with quote

pweil wrote:
And I take it from your reply that PEAR does indeed require you to specify a socket, unlike mysql_connect.


No, it is not required. I'm using MDB2 and a MySQL database without specifying a socket. The need to specify a socket depends on your installation.
Back to top
View user's profile Send private message
pweil



Joined: 07 Feb 2007
Posts: 6

PostPosted: Fri Mar 02, 2007 4:14 pm    Post subject: Reply with quote

mark wrote:
pweil wrote:
And I take it...that PEAR does... require you to specify a socket, unlike mysql_connect.


No, it is not required. I'm using MDB2 and a MySQL database without specifying a socket. The need to specify a socket depends on your installation.


Now you've piqued my curiosity. What about the installation determines whether you need to specify a socket? FWIW, we're running PHP5x/PEAR 1.5/MDB2/MDB2_Driver_mysql, MySQL5x and Fedora core 6. It's not a big deal, but if we can get away with using just 'localhost' and still utilize the UDG socket, it might make things a little easier/simpler.

Thanks again.
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 998

PostPosted: Fri Mar 02, 2007 5:04 pm    Post subject: Reply with quote

pweil wrote:
Now you've piqued my curiosity. What about the installation determines whether you need to specify a socket? FWIW, we're running PHP5x/PEAR 1.5/MDB2/MDB2_Driver_mysql, MySQL5x and Fedora core 6. It's not a big deal, but if we can get away with using just 'localhost' and still utilize the UDG socket, it might make things a little easier/simpler.


I'm sorry, I can only tell you that I don't need to specify a socket - neither on my local Windows machine, nor on about a dozen external Linux machines. The MySQL manual might tell you more about the different installation options.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Database 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

'Actiemonitor' online projectmanagement software