my ($table, @fields, %where, %opt, %values, %set, $sql, @binds);
SQL::Maker - Yet another SQL builder
use SQL::Maker; my $builder = SQL::Maker->new(); # SELECT ($sql, @binds) = $builder->select($table, \@fields, \%where, \%opt); # INSERT ($sql, @binds) = $builder->insert($table, \%values); # DELETE ($sql, @binds) = $builder->delete($table, \%values); # UPDATE ($sql, @binds) = $builder->update($table, \%set, \%where);
SQL::Maker is yet another SQL builder class. It is based on DBIx::Skinny's SQL generator.
Create new instance of SQL::Maker.
Attribuetes are following:
Driver name is required. The driver type is needed to create SQL string.
This is the character that a table or column name will be quoted with.
Default: auto detect from $driver.
This is the character that separates a table and column name.
Default: '.'
This method returns SQL string and bind variables for SELECT statement.
Table name in scalar.
This is a list for retrieving fields from database.
SQL::Maker creates where clause from this hashref via SQL::Maker::Condition.
This is a options for select statemet
This is a prefix for SELECT statement.
For example, you can provide the 'SELECT SQL_CALC_FOUND_ROWS '. It's useful for MySQL.
Default Value: 'SELECT '
This option makes 'LIMIT $n' clause.
This option makes 'OFFSET $n' clause.
This option makes HAVING clause
This option makes 'FOR UPDATE" clause.
Generate INSERT query.
This is a values for INSERT statement.
Generate DELETE query.
Generate UPDATE query.
Setting values.
SQL::Maker supports plugin system. Write the code like following.
package My::SQL::Maker; use parent qw/SQL::Maker/; __PACKAGE__->load_plugin('InsertMulti');
I need more extensible one.
Tokuhiro Matsuno <tokuhirom AAJKLFJEF GMAIL COM>
SQL::Abstract
Whole code was taken from DBIx::Skinny by nekokak++.
Copyright (C) Tokuhiro Matsuno
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install SQL::Maker, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SQL::Maker
CPAN shell
perl -MCPAN -e shell install SQL::Maker
For more information on module installation, please visit the detailed CPAN module installation guide.