Guard dba::lastInsertId() with result conditions
This commit is contained in:
parent
ed2ac8dc03
commit
5ccbc95cef
|
@ -67,8 +67,9 @@ function send_message($recipient = 0, $body = '', $subject = '', $replyto = '')
|
||||||
$fields = array('uid' => local_user(), 'guid' => $conv_guid, 'creator' => $sender_handle,
|
$fields = array('uid' => local_user(), 'guid' => $conv_guid, 'creator' => $sender_handle,
|
||||||
'created' => datetime_convert(), 'updated' => datetime_convert(),
|
'created' => datetime_convert(), 'updated' => datetime_convert(),
|
||||||
'subject' => $subject, 'recips' => $handles);
|
'subject' => $subject, 'recips' => $handles);
|
||||||
dba::insert('conv', $fields);
|
if (dba::insert('conv', $fields)) {
|
||||||
$convid = dba::lastInsertId();
|
$convid = dba::lastInsertId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$convid) {
|
if (!$convid) {
|
||||||
|
@ -80,7 +81,8 @@ function send_message($recipient = 0, $body = '', $subject = '', $replyto = '')
|
||||||
$replyto = $convuri;
|
$replyto = $convuri;
|
||||||
}
|
}
|
||||||
|
|
||||||
q("INSERT INTO `mail` ( `uid`, `guid`, `convid`, `from-name`, `from-photo`, `from-url`,
|
$post_id = null;
|
||||||
|
$result = q("INSERT INTO `mail` ( `uid`, `guid`, `convid`, `from-name`, `from-photo`, `from-url`,
|
||||||
`contact-id`, `title`, `body`, `seen`, `reply`, `replied`, `uri`, `parent-uri`, `created`)
|
`contact-id`, `title`, `body`, `seen`, `reply`, `replied`, `uri`, `parent-uri`, `created`)
|
||||||
VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, %d, '%s', '%s', '%s' )",
|
VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, %d, '%s', '%s', '%s' )",
|
||||||
intval(local_user()),
|
intval(local_user()),
|
||||||
|
@ -99,7 +101,9 @@ function send_message($recipient = 0, $body = '', $subject = '', $replyto = '')
|
||||||
dbesc($replyto),
|
dbesc($replyto),
|
||||||
datetime_convert()
|
datetime_convert()
|
||||||
);
|
);
|
||||||
$post_id = dba::lastInsertId();
|
if ($result) {
|
||||||
|
$post_id = dba::lastInsertId();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -171,11 +175,13 @@ function send_wallmessage($recipient = '', $body = '', $subject = '', $replyto =
|
||||||
|
|
||||||
$handles = $recip_handle . ';' . $sender_handle;
|
$handles = $recip_handle . ';' . $sender_handle;
|
||||||
|
|
||||||
|
$convid = null;
|
||||||
$fields = array('uid' => $recipient['uid'], 'guid' => $conv_guid, 'creator' => $sender_handle,
|
$fields = array('uid' => $recipient['uid'], 'guid' => $conv_guid, 'creator' => $sender_handle,
|
||||||
'created' => datetime_convert(), 'updated' => datetime_convert(),
|
'created' => datetime_convert(), 'updated' => datetime_convert(),
|
||||||
'subject' => $subject, 'recips' => $handles);
|
'subject' => $subject, 'recips' => $handles);
|
||||||
dba::insert('conv', $fields);
|
if (dba::insert('conv', $fields)) {
|
||||||
$convid = dba::lastInsertId();
|
$convid = dba::lastInsertId();
|
||||||
|
}
|
||||||
|
|
||||||
if (!$convid) {
|
if (!$convid) {
|
||||||
logger('send message: conversation not found.');
|
logger('send message: conversation not found.');
|
||||||
|
|
Loading…
Reference in a new issue