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 throughRose::DBand let itsnew()method hand you back an object blessed into whichever class is right for you, according to itsdriver_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 adbhattribute. if adbhalready exists, it's set directly on it. if not, it gets set whenever thedbhgets 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 thedbhis created β it defers to whatever default valueDBD::mysqlchooses instead. it returns the value of the attribute in thedbhif one exists, or the value that will be set when thedbhis next created. and for all the deets on each attribute, go read theDBD::mysqldocumentation π
β 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::Durationobject - a valid interval keyword (according to
validate_interval_keyword) - something that looks like a function call (matches
"/^\w+\(.*\)$/") andkeyword_function_callsis 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 asperl v5.40.1, dated2026-07-31, in theRose::DB::MySQL(3pm)era. slay, log off, hydrate. π β¨π
π¦ where this page comes from
- ubuntu stonking: librose-db-perl 0.788-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms