Rose::DB::MySQL(3pm)

πŸ’– Rose::DB::MySQL πŸ’–

okay bestie, gather round 🫢 this is Rose::DB::MySQL(3pm) from the User Contributed Perl Documentation, aka the MySQL driver class for Rose::DB, and it is lowkey a bop. let's get into it πŸ’…


✨ NAME ✨

Rose::DB::MySQL β€” MySQL driver class for Rose::DB. that's it, that's the vibe 🌸


🌈 SYNOPSIS 🌈

here's the whole situation, copied exactly because we don't play with code:

use Rose::DB;

Rose::DB->register_db(
  domain   => 'development',
  type     => 'main',
  driver   => 'mysql',
  database => 'dev_db',
  host     => 'localhost',
  username => 'devuser',
  password => 'mysecret',
);

Rose::DB->default_domain('development');
Rose::DB->default_type('main');
...

# Set max length of varchar columns used to emulate the array data type
Rose::DB::MySQL->max_array_characters(128);

$db = Rose::DB->new; # $db is really a Rose::DB::MySQL-derived object
...

✨ iconic. no notes. ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜•: when your driver is "mysql", Rose::DB blesses your objects into a class that's derived from Rose::DB::MySQL. that mapping of driver names β†’ class names is configurable, bestie, so if you're curious about it go read the docs for Rose::DB's new() and driver_class() methods. iykyk πŸ”₯

🚨 do not use this class directly. fr fr. you have to go through Rose::DB and let its new() method hand you back an object blessed into whichever class is right for you, according to its driver_class() mappings. that's the whole point. πŸ™ˆ

also, heads up: only the methods that are new here, or that behave differently than their Rose::DB counterparts, are documented on this page. want the full list of methods? the Rose::DB documentation has you covered πŸ’œ


πŸ‘‘ CLASS METHODS πŸ‘‘

πŸ’« coerce_autoincrement_to_serial [BOOL]

get or set a boolean value that says whether or not "auto-increment" columns get treated like they have the column type "serial." if it's true, then "integer" columns get coerced to the "serial" column type, and "bigint" columns use the "bigserial" column type instead. the default value is true βœ…

this setting only kicks in when Rose::DB::Object::Loader is being used to auto-create column metadata based on an existing database schema. so like, it matters in that specific scenario, just so you know 🧚

πŸ’« max_array_characters [INT]

get or set the maximum length of varchar columns used to emulate the array data type. the default value is 255.

here's the thing: MySQL does not have a native "ARRAY" data type 😭 it simply does not. but you can emulate it anyway using a "VARCHAR" column plus a specially formatted string. the formatting and parsing of that string is handled by the format_array and parse_array object methods, and the maximum length limit is honored by the format_array object method. so like, she respects the limit πŸ’…

πŸ’« max_interval_characters [INT]

get or set the maximum length of varchar columns used to emulate the interval data type. the default value is 255.

same struggle, different data type: MySQL does not have a native "interval" data type either πŸ’€ but you can emulate it with a "VARCHAR" column and a specially formatted string. the formatting and parsing of this string is handled by the format_interval and parse_interval object methods, and the maximum length limit is honored by the format_interval object method. periodt 🌟


🌸 OBJECT METHODS 🌸

πŸ’‘ quick lore drop before we get into these: basically every one of the methods below works the same way. it sets a dbh attribute. if a dbh already exists, it's set directly on it. if not, it gets set whenever the dbh gets created. and if no value for the attribute is defined (that's the default, btw), then it just won't be set at all when the dbh is created β€” it defers to whatever default value DBD::mysql chooses instead. it returns the value of the attribute in the dbh if one exists, or the value that will be set when the dbh is next created. and for all the deets on each attribute, go read the DBD::mysql documentation πŸ’–

⭐ mysql_auto_reconnect [BOOL]

get or set the mysql_auto_reconnect database handle attribute. set directly on the dbh if one exists, otherwise it gets set when the dbh is created. if no value for this attribute is defined (which is the default), then it won't be set when the dbh is created β€” she defers to whatever default value DBD::mysql chooses instead πŸ™ˆ

returns the value of this attribute in the dbh if one exists, or the value that will be set when the dbh is next created.

see the DBD::mysql documentation to learn more about this attribute πŸ¦‹

⭐ mysql_bind_type_guessing [BOOL]

get or set the mysql_bind_type_guessing database handle attribute. set directly on the dbh if one exists, otherwise it'll get set when the dbh is created. if no value for this attribute is defined (the default, again), then it won't be set when the dbh is created, deferring to whatever default value DBD::mysql chooses.

returns the value of this attribute in the dbh if one exists, or the value that will be set when the dbh is next created.

see the DBD::mysql documentation to learn more about this attribute πŸ’œ

⭐ mysql_client_found_rows [BOOL]

get or set the mysql_client_found_rows database handle attribute. set directly on the dbh if one exists, otherwise it gets set when the dbh is created. no value defined for this attribute (the default)? then it will not be set when the dbh is created, deferring instead to whatever default value DBD::mysql chooses.

returns the value of this attribute in the dbh if one exists, or the value that will be set when the dbh is next created.

see the DBD::mysql documentation to learn more about this attribute πŸ’…

⭐ mysql_compression [BOOL]

get or set the mysql_compression database handle attribute. it's set directly on the dbh if one exists; otherwise it'll be set when the dbh is created. if no value for this attribute is defined (the default), it will not be set when the dbh is created, deferring to whatever default value DBD::mysql chooses.

returns the value of this attribute in the dbh if one exists, or the value that will be set when the dbh is next created.

see the DBD::mysql documentation to learn more about this attribute πŸ”₯

⭐ mysql_connect_timeout [BOOL]

get or set the mysql_connect_timeout database handle attribute. set directly on the dbh if one exists, otherwise it gets set when the dbh is created. if no value for this attribute is defined (the default), then it won't be set when the dbh is created, deferring instead to whatever default value DBD::mysql chooses.

returns the value of this attribute in the dbh if one exists, or the value that will be set when the dbh is next created.

see the DBD::mysql documentation to learn more about this attribute 🌈

⭐ mysql_embedded_groups [STRING]

get or set the mysql_embedded_groups database handle attribute. set directly on the dbh if one exists; otherwise it will be set when the dbh is created. if no value for this attribute is defined (the default), then it won't be set when the dbh is created, deferring to whatever default value DBD::mysql chooses instead.

returns the value of this attribute in the dbh if one exists, or the value that will be set when the dbh is next created.

see the DBD::mysql documentation to learn more about this attribute ✨

⭐ mysql_embedded_options [STRING]

get or set the mysql_embedded_options database handle attribute. set directly on the dbh if one exists, otherwise it gets set when the dbh is created. if no value for this attribute is defined (the default), it will not be set when the dbh is created β€” she defers to whatever default value DBD::mysql chooses.

returns the value of this attribute in the dbh if one exists, or the value that will be set when the dbh is next created.

see the DBD::mysql documentation to learn more about this attribute πŸŽ€

⭐ mysql_enable_utf8 [BOOL]

get or set the mysql_enable_utf8 database handle attribute. heads up, this one's different bestie πŸ‘€ if a dbh exists, it's set directly on it by executing the SQL SET NAMES utf8. otherwise it gets set when the dbh is created. if no value for this attribute is defined (the default), then it won't be set when the dbh is created, deferring instead to whatever default value DBD::mysql chooses.

returns the value of this attribute in the dbh if one exists, or the value that will be set when the dbh is next created.

see the DBD::mysql documentation to learn more about this attribute πŸ’–

⭐ mysql_enable_utf8mb4 [BOOL]

get or set the mysql_enable_utf8mb4 database handle attribute. and yep, this one also does the SQL thing πŸ‘€ if a dbh exists, it's set directly on it by executing the SQL SET NAMES utf8mb4. otherwise it will be set when the dbh is created. if no value for this attribute is defined (the default), then it will not be set when the dbh is created, deferring to whatever default value DBD::mysql chooses.

returns the value of this attribute in the dbh if one exists, or the value that will be set when the dbh is next created.

see the DBD::mysql documentation to learn more about this attribute 🌟

⭐ mysql_local_infile [STRING]

get or set the mysql_local_infile database handle attribute. set directly on the dbh if one exists, otherwise it gets set when the dbh is created. if no value for this attribute is defined (the default), then it won't be set when the dbh is created, deferring instead to whatever default value DBD::mysql chooses.

returns the value of this attribute in the dbh if one exists, or the value that will be set when the dbh is next created.

see the DBD::mysql documentation to learn more about this attribute πŸ“

⭐ mysql_multi_statements [BOOL]

get or set the mysql_multi_statements database handle attribute. it's set directly on the dbh if one exists; otherwise it will be set when the dbh is created. if no value for this attribute is defined (the default), then it will not be set when the dbh is created, deferring to whatever default value DBD::mysql chooses.

returns the value of this attribute in the dbh if one exists, or the value that will be set when the dbh is next created.

see the DBD::mysql documentation to learn more about this attribute 🧚

⭐ mysql_read_default_file [STRING]

get or set the mysql_read_default_file database handle attribute. set directly on the dbh if one exists, otherwise it gets set when the dbh is created. if no value for this attribute is defined (the default), then it won't be set when the dbh is created, deferring instead to whatever default value DBD::mysql chooses.

returns the value of this attribute in the dbh if one exists, or the value that will be set when the dbh is next created.

see the DBD::mysql documentation to learn more about this attribute πŸ’œ

⭐ mysql_read_default_group [STRING]

get or set the mysql_read_default_group database handle attribute. set directly on the dbh if one exists; otherwise it will be set when the dbh is created. if no value for this attribute is defined (the default), then it will not be set when the dbh is created, deferring to whatever default value DBD::mysql chooses instead.

returns the value of this attribute in the dbh if one exists, or the value that will be set when the dbh is next created.

see the DBD::mysql documentation to learn more about this attribute 🌸


ok bestie that's where part 1 wraps, pt. 2 is pulling up, don't go anywhere 🫢✨

🌸 mysql_socket [STRING]

Bestie, this one gets or sets the mysql_socket database handle attribute. The way it works: if a dbh already exists, it sets the thing directly on the dbh. No dbh yet? Then it just waits and gets set the moment the dbh is created. And if you never define a value for this attribute (which is the default), it will not be set when the dbh is created β€” it defers instead to whatever default value DBD::mysql chooses. Iconic delegation honestly.

Returns the value of this attribute in the dbh, if one exists β€” or the value that will be set when the dbh is next created.

See the DBD::mysql documentation to learn more about this attribute. πŸ’–


✨ mysql_ssl [BOOL]

Get or set the mysql_ssl database handle attribute. Sets directly on the dbh if one exists β€” otherwise it'll be set when the dbh is created. No value defined (the default)? Then it won't be set at dbh creation time at all, and it defers to whatever default DBD::mysql chooses.

Returns the value of this attribute in the dbh, if one exists, or the value that will be set when the dbh is next created.

See the DBD::mysql documentation to learn more about this attribute. πŸ”


πŸŽ€ mysql_ssl_ca_file [STRING]

Get or set the mysql_ssl_ca_file database handle attribute. Directly on the dbh if there's one; otherwise it gets set when the dbh is created. If no value for this attribute is defined (the default), it will not be set when the dbh is created, deferring instead to whatever default value DBD::mysql chooses.

Returns the value of this attribute in the dbh, if one exists, or the value that will be set when the dbh is next created.

See the DBD::mysql documentation to learn more about this attribute. πŸ—‚οΈ


πŸ¦‹ mysql_ssl_ca_path [STRING]

Get or set the mysql_ssl_ca_path database handle attribute. Same deal as its siblings: straight onto the dbh if one exists, otherwise set when the dbh is created. No defined value (the default) means it does not get set at dbh creation, and it defers to whatever default value DBD::mysql chooses.

Returns the value of this attribute in the dbh, if one exists, or the value that will be set when the dbh is next created.

See the DBD::mysql documentation to learn more about this attribute. πŸ’…


πŸ”₯ mysql_ssl_cipher [STRING]

Get or set the mysql_ssl_cipher database handle attribute. Set directly on the dbh if one exists. Otherwise it will be set when the dbh is created. If no value for this attribute is defined (the default) then it will not be set when the dbh is created β€” deferring instead to whatever default value DBD::mysql chooses.

Returns the value of this attribute in the dbh, if one exists, or the value that will be set when the dbh is next created.

See the DBD::mysql documentation to learn more about this attribute. 🫢


πŸ’œ mysql_ssl_client_cert [STRING]

Get or set the mysql_ssl_client_cert database handle attribute. If a dbh exists, this is set directly on it. Otherwise, it gets set when the dbh is created. If no value for this attribute is defined (the default), it will not be set when the dbh is created, deferring instead to whatever default value DBD::mysql chooses.

Returns the value of this attribute in the dbh, if one exists, or the value that will be set when the dbh is next created.

See the DBD::mysql documentation to learn more about this attribute. πŸ“œ


🧚 mysql_ssl_client_key [STRING]

Get or set the mysql_ssl_client_key database handle attribute. The pattern continues, bestie: set directly on the dbh if one exists, otherwise set when the dbh is created. No value defined (the default) means it's not set when the dbh is created, and it defers to whatever default value DBD::mysql chooses.

Returns the value of this attribute in the dbh, if one exists, or the value that will be set when the dbh is next created.

See the DBD::mysql documentation to learn more about this attribute. πŸ”‘


⭐ mysql_use_result [BOOL]

Get or set the mysql_use_result database handle attribute. Set directly on the dbh, if one exists. Otherwise, it will be set when the dbh is created. If no value for this attribute is defined (the default) then it will not be set when the dbh is created, deferring instead to whatever default value DBD::mysql chooses.

Returns the value of this attribute in the dbh, if one exists, or the value that will be set when the dbh is next created.

See the DBD::mysql documentation to learn more about this attribute. πŸ“


🌈 Value Parsing and Formatting 🌈

This is the part where it turns your data into strings and your strings back into data. Glow up both ways. ✨

πŸ’« format_array ARRAYREF | LIST

Hand it a reference to an array, or just a whole list of values, and it gives you back a specially formatted string. Undef is returned if ARRAYREF points to an empty array, or if LIST wasn't passed at all. Heads up though: the array or list must not contain any undefined values.

If the resulting string ends up longer than max_array_characters, it's a fatal error. Not a warning, not a vibe. Fatal.


πŸ’« format_interval DURATION

Give it a DateTime::Duration object and it returns a string formatted according to the rules of PostgreSQL's "INTERVAL" column type. (Yes, PostgreSQL, in a MySQL page. We don't question the lore. πŸ™ˆ)

If DURATION is any of these things, it gets returned unmodified:

  • undefined
  • a DateTime::Duration object
  • a valid interval keyword (according to validate_interval_keyword)
  • something that looks like a function call (matches "/^\w+\(.*\)$/") and keyword_function_calls is true

And if the resulting string is longer than max_interval_characters, you get a fatal error.


πŸ’« format_set ARRAYREF | LIST

Give it an arrayref or a list of values, get back a string formatted according to the rules of MySQL's "SET" data type. Undef is returned if ARRAYREF points to an empty array, or if LIST isn't passed.

But if the array or list contains undefined values? Fatal error. So keep your list clean, bestie. πŸ’€


πŸ’« parse_array STRING | LIST | ARRAYREF

Parses STRING and hands you back a reference to an array. That STRING should be formatted according to the MySQL array data type emulation format returned by format_array(). If STRING is undefined, Undef comes back.

Other behaviours, depending on what you fed it:

  • If a LIST of more than one item is passed, you get a reference to an array containing the values in LIST.
  • If an ARRAYREF is passed, it's returned as-is.

πŸ’« parse_interval STRING

Parses STRING and returns a DateTime::Duration object. That STRING should be formatted according to the PostgreSQL native "interval" data type β€” years, months, days, hours, minutes, seconds.

If STRING is a DateTime::Duration object, a valid interval keyword (per validate_interval_keyword), or it looks like a function call (matches "/^\w+\(.*\)$/") and keyword_function_calls is true, then it is returned unmodified. Otherwise, if STRING couldn't be parsed as a valid "interval" value, you get undef back. 😭


πŸ’« parse_set STRING | LIST | ARRAYREF

Parses STRING and returns a reference to an array. That STRING should be formatted according to MySQL's "SET" data type. If STRING is undefined, Undef is returned.

The other two cases:

  • If a LIST of more than one item is passed, a reference to an array containing the values in LIST is returned.
  • If an ARRAYREF is passed, it is returned as-is.

πŸ‘‘ validate_date_keyword STRING

Returns true if STRING is a valid keyword for the MySQL "date" data type. The valid date keywords, case-insensitive, are giving:

curdate()
current_date
current_date()
now()
sysdate()
00000-00-00

Any string that looks like a function call (matches /^\w+\(.*\)$/) is also considered a valid date keyword β€” but only if keyword_function_calls is true. ✨


πŸ‘‘ validate_datetime_keyword STRING

Returns true if STRING is a valid keyword for the MySQL "datetime" data type, false otherwise. Here's the valid (case-insensitive) datetime keyword lineup:

curdate()
current_date
current_date()
current_time
current_time()
current_timestamp
current_timestamp()
curtime()
now()
sysdate()
0000-00-00 00:00:00

Any string that looks like a function call (matches /^\w+\(.*\)$/) is also considered a valid datetime keyword if keyword_function_calls is true. πŸ’…


πŸ‘‘ validate_timestamp_keyword STRING

Returns true if STRING is a valid keyword for the MySQL "timestamp" data type, false otherwise. And the valid (case-insensitive) timestamp keywords are:

curdate()
current_date
current_date()
current_time
current_time()
current_timestamp
current_timestamp()
curtime()
now()
sysdate()
0000-00-00 00:00:00
00000000000000

Any string that looks like a function call (matches /^\w+\(.*\)$/) is also considered a valid timestamp keyword if keyword_function_calls is true. 🌟


🌸 AUTHOR 🌸

John C. Siracusa (siracusa@gmail.com) β€” the original main character. πŸ‘‘


πŸ’– LICENSE πŸ’–

Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


that's a wrap on the whole page, bestie 🫢 this one shipped as perl v5.40.1, dated 2026-07-31, in the Rose::DB::MySQL(3pm) era. slay, log off, hydrate. πŸ’…βœ¨πŸŒˆ
πŸ“¦ where this page comes from