mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-10 12:32:14 +09:00
Use raw query and prepared statement to update document count
This commit is contained in:
parent
03de7d6392
commit
10cb1b2e20
1 changed files with 4 additions and 10 deletions
|
|
@ -738,24 +738,18 @@ class DocumentAdminController extends Document
|
||||||
public function procDocumentAdminRecalculateCategoryCounts()
|
public function procDocumentAdminRecalculateCategoryCounts()
|
||||||
{
|
{
|
||||||
// Get the document count for each category.
|
// Get the document count for each category.
|
||||||
$oDB = DB::getInstance();
|
|
||||||
$output = executeQueryArray('document.getCategoryDocumentCounts', []);
|
$output = executeQueryArray('document.getCategoryDocumentCounts', []);
|
||||||
$module_srl_list = [];
|
$module_srl_list = [];
|
||||||
|
|
||||||
// Update the document count of each category.
|
// Update the document count of each category.
|
||||||
|
$oDB = DB::getInstance();
|
||||||
$oDB->beginTransaction();
|
$oDB->beginTransaction();
|
||||||
|
$oDB->query('UPDATE document_categories SET document_count = 0');
|
||||||
|
$stmt = $oDB->prepare('UPDATE document_categories SET document_count = ? WHERE category_srl = ?');
|
||||||
foreach ($output->data ?: [] as $row)
|
foreach ($output->data ?: [] as $row)
|
||||||
{
|
{
|
||||||
$module_srl_list[$row->module_srl] = true;
|
$module_srl_list[$row->module_srl] = true;
|
||||||
$output = executeQuery('document.updateCategoryCount', [
|
$stmt->execute([$row->count, $row->category_srl]);
|
||||||
'category_srl' => $row->category_srl,
|
|
||||||
'document_count' => $row->count,
|
|
||||||
]);
|
|
||||||
if (!$output->toBool())
|
|
||||||
{
|
|
||||||
$oDB->rollback();
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$oDB->commit();
|
$oDB->commit();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue