my $uid = $params->{user} || $params->{uid};
my $from_uid = $params->{fuser} || $params->{from_uid};
+ my $id = $params->{id};
+ my $keys = [qw(id user fuser code updated readed date)];
+ my $unique = 0;
if ($uid) {
$where_clause = "message_web.user = ?";
$where_clause = "message_web.fuser = ?";
push @q_args, $from_uid;
}
+ elsif ($id) {
+ $where_clause = "message_web.id = ?";
+ push @q_args, $id;
+ $unique = 1;
+ }
if ($where_clause) {
$where_clause = "WHERE $where_clause";
};
push @q_args, @$values;
}
+ my ($order_by_clause, $values) = $self->build_order_by_clause(keys => $keys,
+ params => $params);
+
my $sql = <<"EOSQL";
SELECT message_web.*,
message_web_text.*,
$sth->execute(@q_args);
my $rs = $sth->fetchall_arrayref({});
$self->disconnect_db;
+
+ return if !$rs;
+ if ($unique) {
+ return $rs->[0];
+ }
return $rs;
}
return if $self->check_readonly;
return if (!$uid || !$title || !$body || !$code);
$options ||= {};
- my $f_uid = $options->{from_uid};
my $sql = <<"EOSQL";
INSERT INTO message_web
return $id;
}
+sub hard_delete {
+ my $self = shift;
+ my $params = {@_};
+
+ my $id = $params->{id};
+ return if !$id;
+
+ my $sql = <<"EOSQL";
+DELETE FROM message_web WHERE id = ?
+EOSQL
+
+ my $dbh = $self->start_transaction;
+ my $rs = $dbh->do($sql, undef, $id);
+ if (!$rs) {
+ $self->rollback;
+ return;
+ }
+
+ $sql = <<"EOSQL";
+DELETE FROM message_web_text WHERE id = ?
+EOSQL
+ $rs = $dbh->do($sql, undef, $id);
+ if (!$rs) {
+ $self->rollback;
+ return;
+ }
+
+ $self->commit;
+ return 1;
+}
+
1;