ClearPress

 view release on metacpan or  search on metacpan

lib/ClearPress/driver/mysql.pm  view on Meta::CPAN

		      $self->{dbport} || q[3306],
                      $dsn_opts;

    eval {
      $self->{dbh} = DBI->connect($dsn,
				  $self->{dbuser} || q[],
				  $self->{dbpass},
				  {
				   RaiseError => 1,
				   AutoCommit => 0,
				   mysql_enable_utf8 => 1,
				  });

      # 2010-05-12 post-connect SET NAMES utf8 demonstrated to work a lot better than connect with mysql_enable_utf8 => 1
      #
      # Using test data: update run set payload='{"comment":"abc øéü"}' where id_run=2;
      #
      # this works on OSX MacPorts MySQL 5.1 but not on CentOS 5.4 MySQL 5.0
      # perl -MDBI -e 'my $dbh  = DBI->connect("DBI:mysql:host=localhost;dbname=ontrackt", "root", "", {RaiseError=>1});$dbh->do(q[update run set payload=? where id_run=2],{},q[abc øéµ]);print $dbh->selectall_arrayref(q[SELECT payload FROM run WHE...
      #
      # this works on OSX and CentOS:
      # perl -MDBI -e 'my $dbh  = DBI->connect("DBI:mysql:host=localhost;dbname=ontrackt", "root", "", {RaiseError=>1});$dbh->do(q[SET NAMES utf8]);$dbh->do(q[update run set payload=? where id_run=2],{},q[abc øéµ]);print $dbh->selectall_arrayref(q...
      #
      # this works on neither OSX nor CentOS
      # perl -MDBI -e 'my $dbh  = DBI->connect("DBI:mysql:host=localhost;dbname=ontrackt", "root", "", {RaiseError=>1,mysql_enable_utf8 =>1});$dbh->do(q[update run set payload=? where id_run=2],{},q[abc øéµ]);print $dbh->selectall_arrayref(q[SELEC...

      $self->{dbh}->do(q[SET NAMES utf8]);

    } or do {
      croak qq[Failed to connect to $dsn using @{[$self->{dbuser}||q['']]}\n$EVAL_ERROR];
    };

    #########
    # rollback any junk left behind if this is a cached handle
    #



( run in 0.221 second using v1.01-cache-2.11-cpan-00829025b61 )