我的网站工作正常,直到我将其部署到heroku,问题是heroku 使用pgsql,而我使用mysql 和laravel 框架。
我的查询是
$patient = Patient::where('patient_address', 'ILIKE' ,'%' . $request->input)->where('patient_sex', 'ILIKE' ,'%' . $request->gender)->whereHas('users', function($q) use($vaccine_id){
$q->where('vaccine_id','ILIKE','%' . $vaccine_id);
})->get();
这是我将其部署到 heroku 时得到的结果
SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: integer ~~* unknown
LINE 1: ...ient_id" = "patients"."PatientID" and "vaccine_id" ILIKE $3)
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. (SQL: select * from "patients" where "patient_address" ILIKE %San Francisco and "patient_sex" ILIKE % and exists (select * from "vaccines" inner join "immunizations" on "vaccines"."VaccineID" = "immunizations"."vaccine_id" where "immunizations"."patient_id" = "patients"."PatientID" and "vaccine_id" ILIKE %))
我尝试过使用像 CAST(vaccine_id AS VARCHAR) 这样的强制转换,但没有收到错误,但它没有返回任何结果。
问题就在这里:
$q->where('vaccine_id','ILIKE','%' . $vaccine_id)
看起来疫苗_id 是整数,并且不能使用运算符 ILIKE 来整数。尝试只使用“=”
如果您想使用 LIKE、ILIKE 或其他文本运算符,则必须将数据转换为文本。在 SQL 中,它必须如下所示:
WHERE "vaccine_id"::text ILIKE val
instead
WHERE "vaccine_id" ILIKE val
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)