About Aura SQL Connection Factory with PDO options

222 views
Skip to first unread message

Sixin Li

unread,
Nov 13, 2013, 1:57:45 PM11/13/13
to aur...@googlegroups.com
Hey,

I was working on a project using the Aura PHP. I realize that I need to set the utf8. According to the manual, this should work

$connection = $connection_factory->newInstance(

        // adapter name
        'mysql',

        // DSN elements for PDO; this can also be
        // an array of key-value pairs
        'host=hostname;dbname=dbname',

        // username for the connection
        'username'
        // password for the connection
        'password',

      array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')
);


However, it's not setting the options to the connection. I found a work around for this (just create a PDO statement with the option then do     $connection->setPdo($pdo);  ), just want to give a heads up. 
 

Hari K T

unread,
Nov 13, 2013, 11:54:01 PM11/13/13
to aur...@googlegroups.com
I tried in console and via php server.

In console I am getting wrong character, but via server I am getting correct value.

Also could you please provide the data you tried ?

I tried for euro symbol. ( € )

Hari K T

You can ring me : +91 9388 75 8821

Skype  : kthari85
Twitter : harikt


--
You received this message because you are subscribed to the Google Groups "The Aura Project for PHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to auraphp+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hari K T

unread,
Nov 14, 2013, 12:15:16 AM11/14/13
to aur...@googlegroups.com
ok. I figured it out .

Try charset=utf8 in dsn string
 

$connection = $connection_factory->newInstance(

        // adapter name
        'mysql',

        // DSN elements for PDO; this can also be
        // an array of key-value pairs

'host=hostname;dbname=dbname;charset=utf8',


 

        // username for the connection
        'username'
        // password for the connection
        'password',

      array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')
);


Hope that help!
Reply all
Reply to author
Forward
0 new messages