pquery($query); echo "vtiger_seattachmentsrel rows: " . $adb->num_rows($result) . "\n"; if ($adb->num_rows($result) > 0) { while ($row = $adb->fetchByAssoc($result)) { echo "Found attachment: " . $row['attachmentsid'] . "\n"; // Проверим vtiger_attachments $query2 = "SELECT * FROM vtiger_attachments WHERE attachmentsid = " . $row['attachmentsid']; $result2 = $adb->pquery($query2); if ($adb->num_rows($result2) > 0) { $att = $adb->fetchByAssoc($result2); echo " - name: " . $att['name'] . "\n"; echo " - path: " . $att['path'] . "\n"; echo " - storedname: " . $att['storedname'] . "\n"; } // Проверим vtiger_notes $query3 = "SELECT s3_url FROM vtiger_notes WHERE notesid = " . $row['attachmentsid']; $result3 = $adb->pquery($query3); if ($adb->num_rows($result3) > 0) { $note = $adb->fetchByAssoc($result3); echo " - s3_url: " . $note['s3_url'] . "\n"; } } } else { echo "No attachments found!\n"; } // Проверим исходный запрос из Telegram.php echo "\nTesting Telegram.php query:\n"; $query = 'SELECT a.attachmentsid, a.name, a.type, a.path, a.storedname, n.s3_url FROM vtiger_seattachmentsrel ar LEFT JOIN vtiger_attachments a ON a.attachmentsid = ar.attachmentsid LEFT JOIN vtiger_notes n ON n.notesid = ar.attachmentsid WHERE ar.crmid = '.$commentid; $result = $adb->pquery($query); echo "Query result rows: " . $adb->num_rows($result) . "\n"; if ($adb->num_rows($result) > 0) { while ($row = $adb->fetchByAssoc($result)) { echo "File found:\n"; echo " - attachmentsid: " . $row['attachmentsid'] . "\n"; echo " - name: " . $row['name'] . "\n"; echo " - s3_url: " . $row['s3_url'] . "\n"; } } ?>