forked from GNUsocial/gnu-social
Use join instead of exists in SQL
This commit is contained in:
parent
4ea79bc396
commit
0177c8f1cf
@ -171,9 +171,14 @@ function initConversation()
|
|||||||
printfnq("Ensuring all conversations have a row in conversation table...");
|
printfnq("Ensuring all conversations have a row in conversation table...");
|
||||||
|
|
||||||
$notice = new Notice();
|
$notice = new Notice();
|
||||||
$notice->query('select distinct notice.conversation from notice '.
|
$notice->selectAdd();
|
||||||
'where notice.conversation is not null '.
|
$notice->selectAdd('DISTINCT conversation');
|
||||||
'and not exists (select conversation.id from conversation where id = notice.conversation)');
|
$notice->joinAdd(['conversation', 'conversation:id'], 'LEFT'); // LEFT to get the null values for conversation.id
|
||||||
|
$notice->whereAdd('conversation.id IS NULL');
|
||||||
|
|
||||||
|
if ($notice->find()) {
|
||||||
|
printfnq(" fixing {$notice->N} missing conversation entries...");
|
||||||
|
}
|
||||||
|
|
||||||
while ($notice->fetch()) {
|
while ($notice->fetch()) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user