NAME
Mojo::MySQL5::Util - Utility functions
SYNOPSIS
use Mojo::MySQL5::Util qw(quote quote_id);
my $str = "I'm happy\n";
my $escaped = quote $str;
DESCRIPTION
Mojo::MySQL5::Util provides utility functions for Mojo::MySQL5.
FUNCTIONS
Mojo::MySQL5::Util implements the following functions, which can be imported individually.
expand_sql
my $sql = expand_sql("select name from table where id=?", $id);
Replace ? in SQL query with quoted arguments.
flag_list \@names, $int, $separator
say flag_list(['one' 'two' 'three'], 3, ','); # one,two
say flag_list(['one' 'two' 'three'], 4, ','); # three
say flag_list(['one' 'two' 'three'], 6); # one|two|three
List bit flags that are set in integer.
flag_set \@names, @flags
say flag_set(['one' 'two' 'three'], 'one', 'two'); # 3
say flag_set(['one' 'two' 'three']) # 0
Set named bit flags.
flag_is \@names, $int, $flag
say flag_is(['one' 'two' 'three'], 1, 'one'); # true
say flag_is(['one' 'two' 'three'], 3, 'two'); # true
say flag_is(['one' 'two' 'three'], 3, 'three'); # false
Check if named bit flag is set.
quote
my $escaped = quote $str;
Quote string value for passing to SQL query.
quote_id
my $escaped = quote_id $id;
Quote identifier for passing to SQL query.