noncent / pdo_class_wrapper

A Class for PDO Wrapper
25 stars 21 forks source link

Connect through unix_socket #2

Closed lesslauer closed 10 years ago

lesslauer commented 10 years ago

Thanks for this great Class! But one think... There's now way to connect an Server through unix_socket- but big Hoster like 1and1 prefer a connection through socket. My Workaround:

try {
    // use native pdo class and connect
    //if connection via socket
    if (isset($dsn['socket'])) {
        parent::__construct("mysql:unix_socket=$socket;dbname=$dbname", $username, $password, array(
            PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"
        ));
    } else {
        //Normal connection
        parent::__construct("mysql:host=$host; dbname=$dbname", $username, $password, array(
            PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"
        ));
    }
}

--> If an Parameter 'socket' is given via db config, the class connect through unix_socket... quick'n'easy, yeah, but it works :-)

noncent commented 10 years ago

Thanks Bro :) sure we will add your idea in next release. You know, when people like your code and gives a nice feedback and suggestion it feels so good and it’s motivate to make more good things. Thanks allot.. :)