こんにちは、Ajax を使用して呼び出してデータベース情報を取得するカスタム スクリプトがありますが、何らかの理由でこのファイルから呼び出しを行うことができません。それでも、テンプレートディレクトリのページにコードを配置すると、 tpl_products_all_default.php と言って、正常に動作します。カスタム スクリプトからクエリを実行できるようにするには、どうすればよいですか?
$sql = "select products_model from products where products_model = :productMdel:";
$sql = $db->bindVars($sql, ':productMdel:', 'C021', 'string');
$result = $db->Execute($sql);
if ($result->RecordCount() > 0) {
echo 'Model number = ' . $result->fields['products_model'];
} else {
echo 'Sorry, no record found for product number ' . $theProductId;
}