## Question Authors' Forum

### PHP quizz with pdo

by Didier BERNARD -
Number of replies: 4

A would like to create a quizz with php code using PDO for accessing sqlite database.

I create a php code runner quizz, for the database, i add in Template params:

{"database_name":"video.db"}

all works fine, but if i try accessing with php PDO, i got this error:

is it impossible to have a pdo usage in php quizz ?

### Re: PHP quizz with pdo

by Richard Lobb -

I've never used PDP PDO, but I don't know of any reason why it won't work from CodeRunner. The error message seems to suggest that PDO isn't actually installed on your Jobe server, though it should be there by default. Do you now anything about your Jobe server, such as whether it's a standard install and what the base OS is (e.g. Ubuntu-20)? If you didn't built it yourself, you could ask whoever did to check whether PDO is installed?

### Re: PHP quizz with pdo

by Didier BERNARD -

ok, i reply to myself. :)

so to make it works, i changed the file application/libraries/php_task.php on the jobe server, and replace the line:

$this->default_params['interpreterargs'] = array('--no-php-ini'); by $this->default_params['interpreterargs'] = array('--no-php-ini -d extension=pdo.so -d extension=pdo_sqlite.so -d extension=json.so');

### Re: PHP quizz with pdo

by Richard Lobb -

Good that you've found a solution, but I'd recommend against editing the Jobe source code as it creates on-going maintenance problems every time a new version is released.

What you've set is the default interpreter args, but you can set explicit interpreter args within the CodeRunner question itself and these will override the default. Customise your question, open the Advanced Customisation panel and in the Sandbox > Parameters field enter what you want, using JSON, e.g.

{"interpreterargs": ["-d blah"]}

Or better, create a new question type and make that change there - then all your questions that need those extensions can be of that new type.

Mind you, I'm not quite sure why you needed to make those changes anyway. The required extensions are clearly all there, just not being used by default. Perhaps as a consequence of the --no-php-ini interpreter arg? Unfortunately I can't remember why I chose to disable php-ini in PHP questions - perhaps it opens a security hole? In any case it might be interesting to try setting the interpreterargs to the empty list to see if that also enables all the missing extensions?