Name

sqlInsert — inserts data into a table or tables in the database

Synopsis

my $rows = $slashdb->sqlInsert($table, $data);
my $rows = $slashdb->sqlInsert($table, $data, $delayed);

sqlInsert creates and executes a SQL statement intended to insert new data into a table or tables. The first two parameters are the same as those for sqlUpdate. The $delayed argument is optional. If it is provided and evaluates to true, the function will perform a delayed insert. This allows the current process to continue immediately. Additionally, the update operation will not preempt any pending reads. In practice, the return value is rarely used. Note that only those fields passed as keys of the hash reference in $data will be inserted. Any other fields in the row will have their default column values.

Example

my %new_user = (     -nickname  => ‘perfesir',     -fakeemail => ‘perf@some.uni',     -sig       => 'π', ); $slashdb->sqlInsert('users', \%new_user);

Get Running Weblogs with Slash now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.