On Tue, Jan 23, 2007 at 11:41:35AM -0500, John Siracusa wrote: > On 1/23/07, Adrian Howard <[EMAIL PROTECTED]> wrote: > > On 23 Jan 2007, at 16:00, David Naughton wrote: > > [snip] > >> The docs say that mysql_enable_utf8 is an "object method", and you're > >> calling it as a class method. > > > > D'oh! I missed the subheading. Obviously need more coffee :) > > > >> In order to enable utf8 for all > >> connections, try this: > >> > >> __PACKAGE__->default_connect_options( mysql_enable_utf8 => 1 ); > > > > Soooper. Ta. > > Is mysql_enable_utf8 a connect option? I thought it was just a $dbh > attribute. Connect options end up going in the "..." part here: > > DBI->connect(<dsn>, <username>, <password>, { ... });
I didn't mention that DBD::mysql provides much TMTOWTDI with respect to utf8. It is a connect option, if this snippet from utf8.t <URL:http://search.cpan.org/src/CAPTTOFU/DBD-mysql-4.001/t/utf8.t> can be trusted: # Connect to the database Test($state or ($dbh = DBI->connect($test_dsn, $test_user, $test_password, {mysql_enable_utf8 => 1}))) or ServerError(); > The default_connect_options() class method and connect_options() > object method are used to set that stuff. > > $dbh attributes, OTOH, get set on the $dbh itself: > > $dbh = DBI->connect(...); > $dbh->{'mysql_enable_utf8'} = 1; > > The mysql_enable_utf8() object method controls that, as set either > directly on the Rose::DB object: > > $db->mysql_enable_utf8(1); > > or indirectly in the registry entry: > > __PACKAGE__->register_db( > driver => 'mysql', > database => 'test', > host => 'localhost', > username => 'me', > password => 'mysecret', > mysql_enable_utf8 => 1, > ); It is also a $dbh attribute, so everything you have above should work, too. I prefer to set mysql_enable_utf8 in the connect options based on this from the DBD::mysql docs <URL:http://search.cpan.org/dist/DBD-mysql/lib/DBD/mysql.pm>: "Additionally, turning on this flag tells MySQL that incoming data should be treated as UTF-8. This will only take effect if used as part of the call to connect(). If you turn the flag on after connecting, you will need to issue the command SET NAMES utf8 to get the same effect." David > -John [..] ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object