Closed vt03 closed 3 months ago
Using the mysql object directly is actually unsupported. Please use use $module->query()
instead.
Okay, thank you. The 'Documentation for Plugins, Hooks, & External Modules' should be updated as under the FAQ Hooks section it states:
### What is the preferred method in a hook for querying REDCap's database tables? It is preferred that you utilize the MySQLi extension when making calls to the database. It is also acceptable to utilize PEAR DB or PDO (if your web server supports it). Please note that REDCap automatically performs a MySQLi connection, so if you wish, your hook may utilize REDCap's existing database connection link, which is a global variable named $conn. If you do, first remember to add the line global $conn; near the beginning of your hook's code, which brings the database connection link into the scope of the hook function.
Yes, it should. That's not the only thing in those old docs that should be updated... I'd recommend focusing on the much newer EM docs (this repo) until someone has a chance to go through all those old docs that predated EMs.
Code that was previously working in PHP 7, does not seem to work in PHP 8.2.
Hook Code:
Error Message:
Changing to use mysqli's method from
to
seems to fix the issue.