<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Mon May 20 03:22:15 UTC 2013

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
For example:
http://www.doctrine-project.org/jira/si/jira.issueviews:issue-xml/DDC-2218/DDC-2218.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Doctrine Project</title>
    <link>http://www.doctrine-project.org/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>5.2.7</version>
        <build-number>850</build-number>
        <build-date>21-02-2013</build-date>
    </build-info>

<item>
            <title>[DDC-2218] Unable to set custom PDO instance</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-2218</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;It&apos;s impossible to set custom instance of PDO using &quot;pdo&quot; parameter in connection params. Its cause errors like this:&lt;/p&gt;

&lt;p&gt;Argument 1 passed to Doctrine\DBAL\Cache\ResultCacheStatement::__construct() must be an instance of Doctrine\DBAL\Driver\Statement, instance of PDOStatement given&lt;/p&gt;

&lt;p&gt;Change &quot;Statement $stmt&quot; to just &quot;$stmt&quot; in Doctrine\DBAL\Cache\ResultCacheStatement constructor parameter list sloved problem.&lt;/p&gt;

&lt;p&gt;Kind regards,&lt;br/&gt;
Micha&#322; Dobaczewski&lt;/p&gt;</description>
                <environment></environment>
            <key id="14342">DDC-2218</key>
            <summary>Unable to set custom PDO instance</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="3" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/major.png">Major</priority>
                    <status id="5" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/resolved.png">Resolved</status>
                    <resolution id="6">Invalid</resolution>
                    <security id="10000">All</security>
                        <assignee username="beberlei">Benjamin Eberlei</assignee>
                                <reporter username="mdobak">Micha&#322; Dobaczewski</reporter>
                        <labels>
                    </labels>
                <created>Mon, 31 Dec 2012 14:40:50 +0000</created>
                <updated>Wed, 1 May 2013 12:56:38 +0000</updated>
                    <resolved>Wed, 1 May 2013 12:56:38 +0000</resolved>
                            <version>2.3.1</version>
                                                        <due></due>
                    <votes>0</votes>
                        <watches>3</watches>
                        <comments>
                    <comment id="19196" author="ocramius" created="Mon, 31 Dec 2012 17:32:54 +0000"  >&lt;p&gt;Shouldn&apos;t you build the driver with your PDO instance?&lt;/p&gt;</comment>
                    <comment id="19197" author="mdobak" created="Tue, 1 Jan 2013 19:13:02 +0000"  >&lt;p&gt;Maybe buld custom driver will be better solution but as long this option is &lt;a href=&quot;http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html&quot; class=&quot;external-link&quot;&gt;in documentation&lt;/a&gt; it should work or it should be deleted from documentation.&lt;/p&gt;</comment>
                    <comment id="19198" author="ocramius" created="Tue, 1 Jan 2013 19:33:02 +0000"  >&lt;p&gt;Could you expose your current config? &lt;/p&gt;</comment>
                    <comment id="19199" author="mdobak" created="Tue, 1 Jan 2013 20:17:11 +0000"  >&lt;p&gt;I have simple configuration without anything unusual based on code from &lt;a href=&quot;http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/configuration.html&quot; class=&quot;external-link&quot;&gt;this page&lt;/a&gt;:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt; 
[...]

$pdoInstance = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; PDO(&apos;mysql:host=localhost;dbname=somedb&apos;, &apos;root&apos;, &apos;mypassword&apos;);

[...]

$connection[&apos;driver&apos;] = &apos;pdo_mysql&apos;;
$connection[&apos;pdo&apos;]    = $pdoInstance; 

[...]

$config = Setup::createConfiguration();

[ Setup annotation driver, cache setup etc. ]

$entityManager = EntityManager::create($connection, $config,  $evm);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 
&lt;p&gt;And now every Doctrine action which use database cause errors. If write this configuration:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
$connection[&apos;driver&apos;]   = &apos;pdo_mysql&apos;;
$connection[&apos;user&apos;]     = &apos;root&apos;;
$connection[&apos;password&apos;] = &apos;mypassword&apos;;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;everything works.&lt;/p&gt;</comment>
                    <comment id="19200" author="ocramius" created="Tue, 1 Jan 2013 22:25:24 +0000"  >&lt;p&gt;Weird... Just went through the code and everything looks fine (See `Doctrine\DBAL\DriverManager#getConnection()`)&lt;/p&gt;

&lt;p&gt;Can you check the spl_object_hash of your PDO instance and the one in the DBAL driver? What&apos;s your `Connection#getDriver()`?&lt;/p&gt;</comment>
                    <comment id="19201" author="mdobak" created="Wed, 2 Jan 2013 09:50:05 +0000"  >&lt;p&gt;I checked the code again and I discovered, that happens If you use Doctrine\ORM\Query\Exec\SingleSelectExecutor with cache but is still a bug. Sorry to confuse you.&lt;/p&gt;</comment>
                    <comment id="19202" author="ocramius" created="Wed, 2 Jan 2013 09:56:15 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=mdobak&quot; class=&quot;user-hover&quot; rel=&quot;mdobak&quot;&gt;Micha&#322; Dobaczewski&lt;/a&gt; can you provide the code to reproduce this then?&lt;/p&gt;</comment>
                    <comment id="19204" author="mdobak" created="Wed, 2 Jan 2013 10:46:40 +0000"  >&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
&amp;lt;?php
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;

require __DIR__ . &apos;/Doctrine/ORM/Tools/Setup.php&apos;;
require __DIR__ . &apos;/Entities/Foo.php&apos;;

Doctrine\ORM\Tools\Setup::registerAutoloadPEAR();

$paths = array(&lt;span class=&quot;code-quote&quot;&gt;&quot;Entities&quot;&lt;/span&gt;);
$isDevMode = &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;;

$pdoInstance = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; PDO(&apos;mysql:host=localhost;dbname=mydb&apos;, &apos;root&apos;, &apos;mypass&apos;);

&lt;span class=&quot;code-comment&quot;&gt;// the connection configuration
&lt;/span&gt;$dbParams = array(
    &apos;driver&apos;   =&amp;gt; &apos;pdo_mysql&apos;,
    &apos;pdo&apos;      =&amp;gt; $pdoInstance
);

$config = Setup::createConfiguration($isDevMode);
$driverImpl = $config-&amp;gt;newDefaultAnnotationDriver(&apos;/Entities&apos;);
$config-&amp;gt;setMetadataDriverImpl($driverImpl);

$em = EntityManager::create($dbParams, $config);

$query = $em-&amp;gt;createQuery(&apos;SELECT e FROM Foo e&apos;);
$query-&amp;gt;useResultCache(&lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;);
$query-&amp;gt;setResultCacheLifetime(3600);
$query-&amp;gt;setResultCacheDriver($em-&amp;gt;getConfiguration()-&amp;gt;getQueryCacheImpl());

&lt;span class=&quot;code-comment&quot;&gt;// Below line is important. It force query to use SQLWalker which use ResultCacheStatement.
&lt;/span&gt;$query-&amp;gt;setHint($query::HINT_CUSTOM_TREE_WALKERS, array(&apos;\Doctrine\ORM\Tools\Pagination\CountWalker&apos;));

$query-&amp;gt;getResult();
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Foo is whatever correct entity.&lt;/p&gt;</comment>
                    <comment id="20155" author="beberlei" created="Wed, 1 May 2013 12:56:38 +0000"  >&lt;p&gt;You need to set the statement to get it working:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
$pdo-&amp;gt;setAttribute(PDO::ATTR_STATEMENT_CLASS, array(&apos;Doctrine\DBAL\Driver\PDOStatement&apos;, array()));
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>