replace all instances of mysqli_fetch_array with mysqli_fetch_assoc for better performance and memory usage

This commit is contained in:
johnnyq
2026-01-14 17:30:23 -05:00
parent cb8b99d6ae
commit 0a30300bde
361 changed files with 1880 additions and 1904 deletions

View File

@@ -20,10 +20,10 @@
<select class="form-control select2" name="file_id">
<option value="">- Select a File -</option>
<?php
$sql_files_select = mysqli_query($mysqli, "SELECT * FROM files
$sql_files_select = mysqli_query($mysqli, "SELECT * FROM files
LEFT JOIN folders ON folder_id = file_folder_id
WHERE file_client_id = $client_id ORDER BY folder_name ASC, file_name ASC");
while ($row = mysqli_fetch_array($sql_files_select)) {
while ($row = mysqli_fetch_assoc($sql_files_select)) {
$file_id = intval($row['file_id']);
$file_name = nullable_htmlentities($row['file_name']);
$folder_name = nullable_htmlentities($row['folder_name']);

View File

@@ -31,7 +31,7 @@ ob_start();
<option value="">- Select Template -</option>
<?php
$sql_document_templates = mysqli_query($mysqli, "SELECT * FROM document_templates WHERE document_template_archived_at IS NULL ORDER BY document_template_name ASC");
while ($row = mysqli_fetch_array($sql_document_templates)) {
while ($row = mysqli_fetch_assoc($sql_document_templates)) {
$document_template_id = intval($row['document_template_id']);
$document_template_name = nullable_htmlentities($row['document_template_name']);
?>
@@ -73,7 +73,7 @@ ob_start();
<option value="0">/</option>
<?php
$sql_folders = mysqli_query($mysqli, "SELECT * FROM folders WHERE folder_client_id = $client_id ORDER BY folder_name ASC");
while ($row = mysqli_fetch_array($sql_folders)) {
while ($row = mysqli_fetch_assoc($sql_folders)) {
$folder_id = intval($row['folder_id']);
$folder_name = nullable_htmlentities($row['folder_name']);
?>

View File

@@ -6,7 +6,7 @@ $document_id = intval($_GET['id']);
$sql = mysqli_query($mysqli, "SELECT * FROM documents WHERE document_id = $document_id LIMIT 1");
$row = mysqli_fetch_array($sql);
$row = mysqli_fetch_assoc($sql);
$document_name = nullable_htmlentities($row['document_name']);
$document_description = nullable_htmlentities($row['document_description']);
$document_content = nullable_htmlentities($row['document_content']);
@@ -46,7 +46,7 @@ ob_start();
<option value="0">/</option>
<?php
$sql_folders_select = mysqli_query($mysqli, "SELECT * FROM folders WHERE folder_client_id = $client_id ORDER BY folder_name ASC");
while ($row = mysqli_fetch_array($sql_folders_select)) {
while ($row = mysqli_fetch_assoc($sql_folders_select)) {
$folder_id_select = intval($row['folder_id']);
$folder_name_select = nullable_htmlentities($row['folder_name']);
?>

View File

@@ -9,7 +9,7 @@ $sql = mysqli_query($mysqli, "SELECT * FROM documents
LIMIT 1
");
$row = mysqli_fetch_array($sql);
$row = mysqli_fetch_assoc($sql);
$document_name = nullable_htmlentities($row['document_name']);
$document_client_visible = intval($row['document_client_visible']);
$client_id = intval($row['document_client_id']);

View File

@@ -9,7 +9,7 @@ $sql = mysqli_query($mysqli, "SELECT * FROM documents
LIMIT 1
");
$row = mysqli_fetch_array($sql);
$row = mysqli_fetch_assoc($sql);
$document_name = nullable_htmlentities($row['document_name']);
$client_id = intval($row['document_client_id']);
@@ -45,7 +45,7 @@ ob_start();
AND asset_documents.asset_id IS NULL
ORDER BY asset_name ASC
");
while ($row = mysqli_fetch_array($sql_assets_select)) {
while ($row = mysqli_fetch_assoc($sql_assets_select)) {
$asset_id = intval($row['asset_id']);
$asset_name = nullable_htmlentities($row['asset_name']);

View File

@@ -9,7 +9,7 @@ $sql = mysqli_query($mysqli, "SELECT * FROM documents
LIMIT 1
");
$row = mysqli_fetch_array($sql);
$row = mysqli_fetch_assoc($sql);
$document_name = nullable_htmlentities($row['document_name']);
$client_id = intval($row['document_client_id']);
@@ -46,7 +46,7 @@ ob_start();
AND contact_documents.contact_id IS NULL
ORDER BY contact_name ASC
");
while ($row = mysqli_fetch_array($sql_contacts_select)) {
while ($row = mysqli_fetch_assoc($sql_contacts_select)) {
$contact_id = intval($row['contact_id']);
$contact_name = nullable_htmlentities($row['contact_name']);

View File

@@ -9,7 +9,7 @@ $sql = mysqli_query($mysqli, "SELECT * FROM documents
LIMIT 1
");
$row = mysqli_fetch_array($sql);
$row = mysqli_fetch_assoc($sql);
$document_name = nullable_htmlentities($row['document_name']);
$client_id = intval($row['document_client_id']);
@@ -48,7 +48,7 @@ ob_start();
AND document_files.file_id IS NULL
ORDER BY folder_name ASC, file_name ASC
");
while ($row = mysqli_fetch_array($sql_files_select)) {
while ($row = mysqli_fetch_assoc($sql_files_select)) {
$file_id = intval($row['file_id']);
$file_name = nullable_htmlentities($row['file_name']);
$folder_name = nullable_htmlentities($row['folder_name']);

View File

@@ -9,7 +9,7 @@ $sql = mysqli_query($mysqli, "SELECT * FROM documents
LIMIT 1
");
$row = mysqli_fetch_array($sql);
$row = mysqli_fetch_assoc($sql);
$document_name = nullable_htmlentities($row['document_name']);
$client_id = intval($row['document_client_id']);
@@ -47,7 +47,7 @@ ob_start();
ORDER BY software_name ASC
");
while ($row = mysqli_fetch_array($sql_software_select)) {
while ($row = mysqli_fetch_assoc($sql_software_select)) {
$software_id = intval($row['software_id']);
$software_name = nullable_htmlentities($row['software_name']);

View File

@@ -9,7 +9,7 @@ $sql = mysqli_query($mysqli, "SELECT * FROM documents
LIMIT 1
");
$row = mysqli_fetch_array($sql);
$row = mysqli_fetch_assoc($sql);
$document_name = nullable_htmlentities($row['document_name']);
$client_id = intval($row['document_client_id']);
@@ -46,7 +46,7 @@ ob_start();
AND vendor_documents.vendor_id IS NULL
ORDER BY vendor_name ASC
");
while ($row = mysqli_fetch_array($sql_vendors_select)) {
while ($row = mysqli_fetch_assoc($sql_vendors_select)) {
$vendor_id = intval($row['vendor_id']);
$vendor_name = nullable_htmlentities($row['vendor_name']);

View File

@@ -5,8 +5,8 @@ require_once '../../../includes/modal_header.php';
$document_id = intval($_GET['id']);
$sql = mysqli_query($mysqli, "SELECT * FROM documents WHERE document_id = $document_id LIMIT 1");
$row = mysqli_fetch_array($sql);
$row = mysqli_fetch_assoc($sql);
$client_id = intval($row['document_client_id']);
$document_folder_id = nullable_htmlentities($row['document_folder_id']);
$document_name = nullable_htmlentities($row['document_name']);

View File

@@ -5,8 +5,8 @@ require_once '../../../includes/modal_header.php';
$document_id = intval($_GET['id']);
$sql = mysqli_query($mysqli, "SELECT * FROM documents WHERE document_id = $document_id LIMIT 1");
$row = mysqli_fetch_array($sql);
$row = mysqli_fetch_assoc($sql);
$client_id = intval($row['document_client_id']);
$document_name = nullable_htmlentities($row['document_name']);

View File

@@ -13,8 +13,8 @@ $purifier = new HTMLPurifier($purifier_config);
$document_version_id = intval($_GET['id']);
$sql = mysqli_query($mysqli, "SELECT * FROM document_versions WHERE document_version_id = $document_version_id LIMIT 1");
$row = mysqli_fetch_array($sql);
$row = mysqli_fetch_assoc($sql);
$document_version_name = nullable_htmlentities($row['document_version_name']);
$document_version_content = $purifier->purify($row['document_version_content']);

View File

@@ -13,8 +13,8 @@ $purifier = new HTMLPurifier($purifier_config);
$document_id = intval($_GET['id']);
$sql = mysqli_query($mysqli, "SELECT * FROM documents WHERE document_id = $document_id LIMIT 1");
$row = mysqli_fetch_array($sql);
$row = mysqli_fetch_assoc($sql);
$document_name = nullable_htmlentities($row['document_name']);
$document_content = $purifier->purify($row['document_content']);