| 1 | |||
| 2 | package DBIx::Romani::Driver::mysql; | ||
| 3 | use base qw(DBIx::Romani::Driver); | ||
| 4 | |||
| 5 | use DBIx::Romani::Driver::mysql::IdGenerator; | ||
| 6 | use strict; | ||
| 7 | |||
| 8 | # TODO: this function will take a "Roma-style" DSN or hash, and make | ||
| 9 | # a DBI connection returning a dbh. | ||
| 10 | sub connect_dbi | ||
| 11 | { | ||
| 12 | die "Unimplemented."; | ||
| 13 | } | ||
| 14 | |||
| 15 | sub apply_limit | ||
| 16 | { | ||
| 17 | my ($self, $sql, $offset, $limit) = @_; | ||
| 18 | |||
| 19 | if ( $limit > 0 ) | ||
| 20 | { | ||
| 21 | $sql .= " LIMIT " . $limit; | ||
| 22 | if ( $offset > 0 ) | ||
| 23 | { | ||
| 24 | $sql .= " OFFSET " . $offset; | ||
| 25 | } | ||
| 26 | } | ||
| 27 | elsif ( $offset > 0 ) | ||
| 28 | { | ||
| 29 | $sql .= " LIMIT " . $offset . ", 18446744073709551615"; | ||
| 30 | } | ||
| 31 | |||
| 32 | return $sql; | ||
| 33 | } | ||
| 34 | |||
| 35 | sub create_id_generator | ||
| 36 | { | ||
| 37 | my ($self, $conn) = @_; | ||
| 38 | return DBIx::Romani::Driver::mysql::IdGenerator->new( $conn ); | ||
| 39 | } | ||
| 40 | |||
| 41 | 1; | ||
| 42 |