<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Zucchidoctrine on PHP Boy Scout</title><link>https://blog-570662.gitlab.io/tags/zucchidoctrine/</link><description>Recent content in Zucchidoctrine on PHP Boy Scout</description><generator>Hugo -- gohugo.io</generator><language>en-gb</language><copyright>Matt Cockayne</copyright><lastBuildDate>Fri, 26 Jul 2013 00:00:00 +0000</lastBuildDate><atom:link href="https://blog-570662.gitlab.io/tags/zucchidoctrine/index.xml" rel="self" type="application/rss+xml"/><item><title>Enabling MYSQL_CLIENT_INTERACTIVE with Doctrine 2 on Rackspace Cloud Database</title><link>https://blog-570662.gitlab.io/mysql-client-interactive-with-doctrine-on-rackspace/</link><pubDate>Fri, 26 Jul 2013 00:00:00 +0000</pubDate><guid>https://blog-570662.gitlab.io/mysql-client-interactive-with-doctrine-on-rackspace/</guid><description>&lt;p&gt;We recently ran into problem using Doctrine 2 connecting to a Rackspace Cloud Database using the MySqli Driver.&lt;/p&gt;
&lt;p&gt;Problem:&lt;/p&gt;
&lt;p&gt;We have a long running PHP script that can sometimes run for hours at a time whilst processing information. This script requires a connection to a database, but has long periods of inactivity where there is no actual interaction with MySQL. By default MySQL uses the &amp;ldquo;wait_timeout&amp;rdquo; setting which states, how long an inactive connection can exist before it is killed. This is normally fine with web pages requests, as it is usually a short lived request. Unfortunately you do not have the ability to alter this setting when using Rackspaces Cloud Database.&lt;/p&gt;
&lt;p&gt;Solution:&lt;/p&gt;
&lt;p&gt;When using the MySQLi extension you can create a connection in &amp;ldquo;interactive mode&amp;rdquo; by passing the &amp;ldquo;MYSQLI_CLIENT_INTERACTIVE&amp;rdquo; flag, which will then use the &amp;ldquo;interactive_timeout&amp;rdquo; setting. On Rackspace this is set to 8 hours!&lt;/p&gt;
&lt;p&gt;Annoyingly Doctrine does not allow you to pass any flags to the MySQLi Connection. So we overrode Doctrine\DBAL\Driver\Connection with our own &lt;a class="link" href="https://github.com/zucchi/ZucchiDoctrine/blob/master/src/ZucchiDoctrine/Driver/Mysqli/MysqliConnection.php" title="ZucchiDoctrine/Driver/Mysqli/MysqliConnection.php"
 target="_blank" rel="noopener"
 &gt;Driver&lt;/a&gt; which then allows us to pass a &amp;ldquo;flags&amp;rdquo; parameter through.&lt;/p&gt;
&lt;p&gt;Feel free to look at some of the other helpful features in we have added to Doctrine 2 here: &lt;a class="link" href="https://github.com/zucchi/ZucchiDoctrine" title="ZucchiDoctrine"
 target="_blank" rel="noopener"
 &gt;ZucchiDoctrine&lt;/a&gt;&lt;/p&gt;</description></item></channel></rss>