DB-Object
view release on metacpan or search on metacpan
lib/DB/Object/Mysql/Tables.pm view on Meta::CPAN
# Would return only: my_table
See L<MyQL documentation for more information|https://dev.mysql.com/doc/refman/5.7/en/identifier-qualifiers.html>
=head2 rename
Provided with a new table name, and this will prepare the necessary query to rename the table and return the statement handler.
If it is called in void context, the statement handler is executed immediately.
# Get the prefs table object
my $tbl = $dbh->pref;
$tbl->rename( 'prefs' );
# Would issue a statement handler for the query: ALTER TABLE pref RENAME TO prefs
It returns the statement handler created.
See L<PostgreSQL documentation for more information|https://dev.mysql.com/doc/refman/5.7/en/alter-table.html>
=head2 repair
Provided with an optional hash or hash reference of parameter, and this will prepare a query to C<repair> the MySQL table.
my $tbl = $dbh->my_table || die( $dbh->error );
lib/DB/Object/Postgres.pm view on Meta::CPAN
die( "Error while create query to add data to table customers: " . $cust->error );
};
$result = $cust_sth_ins->as_string;
# INSERT INTO customers (first_name, last_name, email, active) VALUES('Paul', 'Goldman', 'paul\@example.org', '0')
$dbh->commit;
# and more elaborate:
# Ref: https://www.postgresql.org/docs/10/sql-insert.html#SQL-ON-CONFLICT
$login->on_conflict({
# mandatory, can be a constraint name or a field name or array of fields
target => 'on constraint idx_prefs_unique',
action => 'update',
# where => '',
# which fields to update. It can also be more specific by providing a hash ref like fields => { val => 'plop' }
fields => [qw( val )],
});
# would become:
insert into login (..) values(...) on conflict on constraint idx_prefs_unique do update set val = EXCLUDED.val;
# Get the last used insert id
my $id = $dbh->last_insert_id();
$cust->where( email => 'john@example.org' );
$cust->order( 'last_name' );
$cust->having( email => qr/\@example/ );
$cust->limit( 10 );
my $cust_sth_sel = $cust->select || die( "An error occurred while creating a query to select data frm table customers: " . $cust->error );
# Becomes:
lib/DB/Object/Postgres/Tables.pm view on Meta::CPAN
$tbl->prefixed(1);
$tbl->qualified_name;
# Would return only: my_table
=head2 rename
Provided with a new table name, and this will prepare the necessary query to rename the table and return the statement handler.
If it is called in void context, the statement handler is executed immediately.
# Get the prefs table object
my $tbl = $dbh->pref;
$tbl->rename( 'prefs' );
# Would issue a statement handler for the query: ALTER TABLE pref RENAME TO prefs
See L<PostgreSQL documentation for more information|https://www.postgresql.org/docs/9.5/sql-altertable.html>
=head2 repair
Not implemented in PostgreSQL.
=head2 stat
Not implemented in PostgreSQL.
lib/DB/Object/SQLite/Tables.pm view on Meta::CPAN
A convenient wrapper to L<DB::Object::Postgres::Query/on_conflict>
This feature is available in SQLite since version 3.35.0 released on 2021-03-12. If your version of SQLite is anterior, this will return an error.
=head2 rename
Provided with a new table name, and this will prepare the necessary query to rename the table and return the statement handler.
If it is called in void context, the statement handler is executed immediately.
# Get the prefs table object
my $tbl = $dbh->pref;
$tbl->rename( 'prefs' );
# Would issue a statement handler for the query: ALTER TABLE pref RENAME TO prefs
See L<SQLite documentation for more information|https://www.sqlite.org/lang_altertable.html>
=head2 structure
This returns in list context an hash and in scalar context an hash reference of the table structure.
The hash, or hash reference returned contains the column name and its definition.
This method will also set the following object properties:
( run in 0.692 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )