如何指定Doctrine必须使用mysqli连接

while executing a long script that uses Doctrine to access the db, I get an error 2006 server has gone away.

I've already solved this problem on a website that doens't use Doctrine. The solution there was to use mysqli instead of the normal mysql driver.

How can i tell Doctrine to use a mysqli-driver in order to avoid 2006-errors?

Thanks!

I don't think you will be able to do this, because Doctrine uses PDO rather than the older mysqli or mysql extensions.

You can try this:

$masterConn->getDbh()->setAttribute(PDO::ATTR_PERSISTENT, false);

If prepared statements are used, add this,

$masterConn->getDbh()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);

Doctrine can be told to use Mysqli by specifying the mysqli driver. See the documentation for the Mysqli driver's options