Skip to main content
Topic: Error 500 on rawQuery() (Read 1142 times) previous topic - next topic

Error 500 on rawQuery()

On Add page, CustomView is added. In the code I try to use rawQuery but I get Error 500.

Code: [Select]
<?php echo ($db->rawQuery("SELECT sastojci_mit_id FROM sastojci WHERE sastojci_mit_id < 51000 ORDER by sastojci_mit_id DESC LIMIT 1")); ?>

Produces:
Error 500: Call to a member function rawQuery() on null

Shouldn't $db be allays available?

Many thanks!

Re: Error 500 on rawQuery()

Reply #1
@pivar‍ $db is only available on the controller files. Page Event is generated on controller files that are why you can use them there. The Custom View is for HTML, CSS, and JS and you are advised not to use it there for security reasons.