Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Modifying data.

Quote Reply
Modifying data.
I have enough command on DBSql now to run select, delete, insert commands within my Template Globals by creating subs e.g

------------------------------ FOR SELECT ---------------------------
my $sth = $DB->table('main')->select({'USERID' => $userid, 'STATUS' => $status, 'JOB' => $job})->fetchrow_array;
----------------------------------------------------------------------
------------------------------ FOR INSERT ---------------------------
my $sth = $DB->table('main')->insert({ ID => "", MAIN_ID => $id, CLIENT => $client, TEMPLATE => $template, USERID => $userid });
----------------------------------------------------------------------

The above two are just example, Now I am at a loss as what should be the UPDATE statement handle or how should it look like when I will be using it with Template Globals to call it within templates as <%mymodify($ID)%>

Can someone give me any idea as how to UPDATE a field using Template Globals subs?
Quote Reply
Re: [samsara] Modifying data. In reply to
Here is the command for updating data:

if ($DB->table('main')->update({ column1 => new_value1, column2 => new_value2... }, { pk_column => value})) {
print "UPDATED.";
}
else {
print "Error: $GT::SQL::error";
}

Hope that helps.

TheStone


B.