mirror of
https://github.com/itflow-org/itflow
synced 2026-08-15 12:05:11 +00:00
More sweeps to replace select * with actual returned column names dramatically reduces php memory usage and speeds up processing dramatically especially in the crons since they run all the time
This commit is contained in:
@@ -6,7 +6,15 @@ enforceUserPermission('module_support');
|
||||
|
||||
$asset_id = intval($_GET['id']);
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM assets
|
||||
$sql = mysqli_query($mysqli, "SELECT asset_contact_id, asset_created_at, asset_description, asset_favorite, asset_id,
|
||||
asset_install_date, asset_location_id, asset_make, asset_model, asset_name, asset_notes,
|
||||
asset_os, asset_photo, asset_physical_location, asset_purchase_date,
|
||||
asset_purchase_reference, asset_serial, asset_status, asset_type, asset_uri, asset_uri_2,
|
||||
asset_uri_client, asset_vendor_id, asset_warranty_expire, client_id, client_name,
|
||||
contact_archived_at, contact_email, contact_extension, contact_mobile,
|
||||
contact_mobile_country_code, contact_name, contact_phone, contact_phone_country_code,
|
||||
interface_ip, interface_ipv6, interface_mac, interface_nat_ip, interface_network_id,
|
||||
location_archived_at, location_name FROM assets
|
||||
LEFT JOIN clients ON client_id = asset_client_id
|
||||
LEFT JOIN contacts ON asset_contact_id = contact_id
|
||||
LEFT JOIN locations ON asset_location_id = location_id
|
||||
@@ -82,7 +90,7 @@ if ($location_archived_at) {
|
||||
// Tags - many to many relationship
|
||||
$asset_tag_name_display_array = array();
|
||||
$asset_tag_id_array = array();
|
||||
$sql_asset_tags = mysqli_query($mysqli, "SELECT * FROM asset_tags LEFT JOIN tags ON asset_tag_tag_id = tag_id WHERE asset_tag_asset_id = $asset_id ORDER BY tag_name ASC");
|
||||
$sql_asset_tags = mysqli_query($mysqli, "SELECT tag_color, tag_icon, tag_id, tag_name FROM asset_tags LEFT JOIN tags ON asset_tag_tag_id = tag_id WHERE asset_tag_asset_id = $asset_id ORDER BY tag_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_asset_tags)) {
|
||||
|
||||
$asset_tag_id = intval($row['tag_id']);
|
||||
@@ -200,7 +208,7 @@ $sql_related_documents = mysqli_query($mysqli, "SELECT document_created_at, docu
|
||||
$document_count = mysqli_num_rows($sql_related_documents);
|
||||
|
||||
// Related Files
|
||||
$sql_related_files = mysqli_query($mysqli, "SELECT * FROM asset_files
|
||||
$sql_related_files = mysqli_query($mysqli, "SELECT file_created_at, file_description, file_ext, files.file_id, file_mime_type, file_name FROM asset_files
|
||||
LEFT JOIN files ON asset_files.file_id = files.file_id
|
||||
WHERE asset_files.asset_id = $asset_id
|
||||
AND file_archived_at IS NULL
|
||||
@@ -573,7 +581,7 @@ ob_start();
|
||||
// Tags
|
||||
$credential_tag_name_display_array = array();
|
||||
$credential_tag_id_array = array();
|
||||
$sql_credential_tags = mysqli_query($mysqli, "SELECT * FROM credential_tags LEFT JOIN tags ON credential_tags.tag_id = tags.tag_id WHERE credential_id = $credential_id ORDER BY tag_name ASC");
|
||||
$sql_credential_tags = mysqli_query($mysqli, "SELECT tag_color, tag_icon, credential_tags.tag_id, tag_name FROM credential_tags LEFT JOIN tags ON credential_tags.tag_id = tags.tag_id WHERE credential_id = $credential_id ORDER BY tag_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_credential_tags)) {
|
||||
|
||||
$credential_tag_id = intval($row['tag_id']);
|
||||
|
||||
@@ -37,7 +37,7 @@ ob_start();
|
||||
<select class="form-control select2" name="tags[]" data-placeholder="Add some tags" multiple>
|
||||
<?php
|
||||
|
||||
$sql_tags_select = mysqli_query($mysqli, "SELECT * FROM tags WHERE tag_type = 5 ORDER BY tag_name ASC");
|
||||
$sql_tags_select = mysqli_query($mysqli, "SELECT tag_id, tag_name FROM tags WHERE tag_type = 5 ORDER BY tag_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_tags_select)) {
|
||||
$tag_id_select = intval($row['tag_id']);
|
||||
$tag_name_select = escapeHtml($row['tag_name']);
|
||||
|
||||
@@ -6,7 +6,12 @@ enforceUserPermission('module_support', 2);
|
||||
|
||||
$asset_id = intval($_GET['id']);
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM assets
|
||||
$sql = mysqli_query($mysqli, "SELECT asset_archived_at, asset_client_id, asset_contact_id, asset_created_at, asset_description,
|
||||
asset_id, asset_install_date, asset_location_id, asset_make, asset_model, asset_name,
|
||||
asset_notes, asset_os, asset_photo, asset_physical_location, asset_purchase_date,
|
||||
asset_purchase_reference, asset_serial, asset_status, asset_type, asset_uri, asset_uri_2,
|
||||
asset_vendor_id, asset_warranty_expire, interface_ip, interface_ipv6, interface_mac,
|
||||
interface_nat_ip, interface_network_id FROM assets
|
||||
LEFT JOIN asset_interfaces ON interface_asset_id = asset_id AND interface_primary = 1
|
||||
WHERE asset_id = $asset_id LIMIT 1"
|
||||
);
|
||||
|
||||
@@ -6,7 +6,12 @@ enforceUserPermission('module_support', 2);
|
||||
|
||||
$asset_id = intval($_GET['id']);
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM assets
|
||||
$sql = mysqli_query($mysqli, "SELECT asset_archived_at, asset_client_id, asset_contact_id, asset_created_at, asset_description,
|
||||
asset_favorite, asset_id, asset_install_date, asset_location_id, asset_make, asset_model,
|
||||
asset_name, asset_notes, asset_os, asset_photo, asset_physical_location,
|
||||
asset_purchase_date, asset_purchase_reference, asset_serial, asset_status, asset_type,
|
||||
asset_uri, asset_uri_2, asset_uri_client, asset_vendor_id, asset_warranty_expire,
|
||||
interface_ip, interface_ipv6, interface_mac, interface_nat_ip, interface_network_id FROM assets
|
||||
LEFT JOIN asset_interfaces ON interface_asset_id = asset_id AND interface_primary = 1
|
||||
WHERE asset_id = $asset_id LIMIT 1"
|
||||
);
|
||||
@@ -47,7 +52,7 @@ $asset_network_id = intval($row['interface_network_id']);
|
||||
$device_icon = getAssetIcon($asset_type);
|
||||
|
||||
// Asset History Query
|
||||
$sql_asset_history = mysqli_query($mysqli, "SELECT * FROM asset_history
|
||||
$sql_asset_history = mysqli_query($mysqli, "SELECT asset_history_created_at, asset_history_description, asset_history_status FROM asset_history
|
||||
WHERE asset_history_asset_id = $asset_id
|
||||
ORDER BY asset_history_id
|
||||
DESC LIMIT 10"
|
||||
@@ -506,7 +511,7 @@ ob_start();
|
||||
<select class="form-control select2" name="tags[]" data-placeholder="Add some tags" multiple>
|
||||
<?php
|
||||
|
||||
$sql_tags_select = mysqli_query($mysqli, "SELECT * FROM tags WHERE tag_type = 5 ORDER BY tag_name ASC");
|
||||
$sql_tags_select = mysqli_query($mysqli, "SELECT tag_id, tag_name FROM tags WHERE tag_type = 5 ORDER BY tag_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_tags_select)) {
|
||||
$tag_id_select = intval($row['tag_id']);
|
||||
$tag_name_select = escapeHtml($row['tag_name']);
|
||||
|
||||
@@ -4,7 +4,9 @@ require_once '../../../includes/modal_header.php';
|
||||
|
||||
$interface_id = intval($_GET['id']);
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM asset_interfaces
|
||||
$sql = mysqli_query($mysqli, "SELECT asset_client_id, asset_name, interface_asset_id, interface_description, interface_id,
|
||||
interface_ip, interface_ipv6, interface_mac, interface_name, interface_nat_ip,
|
||||
interface_network_id, interface_notes, interface_primary, interface_type FROM asset_interfaces
|
||||
LEFT JOIN assets ON asset_id = interface_asset_id
|
||||
WHERE interface_id = $interface_id LIMIT 1"
|
||||
);
|
||||
|
||||
@@ -6,7 +6,7 @@ enforceUserPermission('module_credential', 2);
|
||||
|
||||
$asset_id = intval($_GET['id']);
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM assets
|
||||
$sql = mysqli_query($mysqli, "SELECT asset_client_id, asset_name FROM assets
|
||||
WHERE asset_id = $asset_id
|
||||
LIMIT 1
|
||||
");
|
||||
|
||||
@@ -4,7 +4,7 @@ require_once '../../../includes/modal_header.php';
|
||||
|
||||
$asset_id = intval($_GET['id']);
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM assets
|
||||
$sql = mysqli_query($mysqli, "SELECT asset_client_id, asset_name FROM assets
|
||||
WHERE asset_id = $asset_id
|
||||
LIMIT 1
|
||||
");
|
||||
|
||||
@@ -6,7 +6,7 @@ enforceUserPermission('module_credential', 2);
|
||||
|
||||
$asset_id = intval($_GET['id']);
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM assets
|
||||
$sql = mysqli_query($mysqli, "SELECT asset_client_id, asset_name FROM assets
|
||||
WHERE asset_id = $asset_id
|
||||
LIMIT 1
|
||||
");
|
||||
|
||||
@@ -4,7 +4,7 @@ require_once '../../../includes/modal_header.php';
|
||||
|
||||
$asset_id = intval($_GET['id']);
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM assets
|
||||
$sql = mysqli_query($mysqli, "SELECT asset_client_id, asset_name FROM assets
|
||||
WHERE asset_id = $asset_id
|
||||
LIMIT 1
|
||||
");
|
||||
|
||||
@@ -4,7 +4,7 @@ require_once '../../../includes/modal_header.php';
|
||||
|
||||
$asset_id = intval($_GET['id']);
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM assets
|
||||
$sql = mysqli_query($mysqli, "SELECT asset_client_id, asset_name FROM assets
|
||||
WHERE asset_id = $asset_id
|
||||
LIMIT 1
|
||||
");
|
||||
|
||||
Reference in New Issue
Block a user