diff options
| author | Michael Foster <savetheinternet@tinyboard.org> | 2013-08-29 12:38:37 +1000 |
|---|---|---|
| committer | Michael Foster <savetheinternet@tinyboard.org> | 2013-08-29 12:38:37 +1000 |
| commit | d7fc5adc22c71261dd3f4544a3a5a1816b8d724e (patch) | |
| tree | e8d1d2be5dcd72e2bb386e2cb86efecca7fadd04 | |
| parent | 0bb254fdb37990958b17c1c72b59f747eab2e3f0 (diff) | |
Performance: Use only one INSERT INTO (with multiple rows) for tracked cites
| -rw-r--r-- | post.php | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -682,15 +682,14 @@ if (isset($_POST['delete'])) { incrementSpamHash($post['antispam_hash']); } - if (isset($post['tracked_cites'])) { + if (isset($post['tracked_cites']) && count($post['tracked_cites'])) { + $insert_rows = array(); foreach ($post['tracked_cites'] as $cite) { - $query = prepare('INSERT INTO ``cites`` VALUES (:board, :post, :target_board, :target)'); - $query->bindValue(':board', $board['uri']); - $query->bindValue(':post', $id, PDO::PARAM_INT); - $query->bindValue(':target_board',$cite[0]); - $query->bindValue(':target', $cite[1], PDO::PARAM_INT); - $query->execute() or error(db_error($query)); + $insert_rows[] = '(' . + $pdo->quote($board['uri']) . ', ' . (int)$id . ', ' . + $pdo->quote($cite[0]) . ', ' . (int)$cite[1] . ')'; } + query('INSERT INTO ``cites`` VALUES ' . implode(', ', $insert_rows)) or error(db_error());; } if (!$post['op'] && strtolower($post['email']) != 'sage' && !$thread['sage'] && ($config['reply_limit'] == 0 || $numposts['replies']+1 < $config['reply_limit'])) { |
