Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Invalid
    • Affects Version/s: 2.3
    • Fix Version/s: None
    • Component/s: DQL, ORM
    • Security Level: All
    • Labels:
    • Environment:
      linux , php 5.4.8, mysql 5.5.28

      Description

      I have a problem when I get database records through a query DQL
      and then they are changed by another application
      If I repeat the query, Doctrine always return the first value, not the current value of the base

      <?php
      
      // bootstrap
      
      $cache = new \Doctrine\Common\Cache\ArrayCache();
      $config = new Doctrine\ORM\Configuration();
      $config->setQueryCacheImpl($cache);
      $conn = array(
      				'dbname' => $database_name,
      				'user' => $cnx_user,
      				'password' => $cnx_pass,
      				'host' => $cnx_host,
      				'driver' => $cnx_type,
      				'charset' => 'utf8',
      				'driverOptions' => array( 1002 => "SET NAMES 'utf8'" )
      				);
      
      			$em = Doctrine\ORM\EntityManager::create($conn, $config);
      
      
      
      
      
      while(true){
         $dql = "SELECT s from Register s WHERE s.id = 1";
         $query = $em->createQuery($dql);
      // the next line is optional, produces same result
         $query->useResultCache(false);
         $res = $query->getResult();
         $orm = reset($res);
         	
         echo " regiter id :".$orm->getId()."  field "$orm->getText()."\n";
      
      }
      

      I run this code in a terminal, and then edit the registry (field text), but the terminal still shows the same result

        Activity

        gabriel sancho created issue -
        gabriel sancho made changes -
        Field Original Value New Value
        Description I have a problem when I get database records through a query DQL
          and then they are changed by another application
        If I repeat the query, Doctrine always return the first value, not the current value of the base

        I have a problem when I get database records through a query DQL
          and then they are changed by another application
        If I repeat the query, Doctrine always return the first value, not the current value of the base

        <code>
        gabriel sancho made changes -
        Description I have a problem when I get database records through a query DQL
          and then they are changed by another application
        If I repeat the query, Doctrine always return the first value, not the current value of the base

        <code>
        I have a problem when I get database records through a query DQL
          and then they are changed by another application
        If I repeat the query, Doctrine always return the first value, not the current value of the base

        <php>

        echo "";
        </php>
        gabriel sancho made changes -
        Description I have a problem when I get database records through a query DQL
          and then they are changed by another application
        If I repeat the query, Doctrine always return the first value, not the current value of the base

        <php>

        echo "";
        </php>
        I have a problem when I get database records through a query DQL
          and then they are changed by another application
        If I repeat the query, Doctrine always return the first value, not the current value of the base

        {code:php}

        echo "";
        {/code}
        gabriel sancho made changes -
        Description I have a problem when I get database records through a query DQL
          and then they are changed by another application
        If I repeat the query, Doctrine always return the first value, not the current value of the base

        {code:php}

        echo "";
        {/code}
        I have a problem when I get database records through a query DQL
          and then they are changed by another application
        If I repeat the query, Doctrine always return the first value, not the current value of the base

        {code}

        echo "";
        {/code}
        gabriel sancho made changes -
        Description I have a problem when I get database records through a query DQL
          and then they are changed by another application
        If I repeat the query, Doctrine always return the first value, not the current value of the base

        {code}

        echo "";
        {/code}
        I have a problem when I get database records through a query DQL
          and then they are changed by another application
        If I repeat the query, Doctrine always return the first value, not the current value of the base

        {code}

        echo "";

        gabriel sancho made changes -
        Description I have a problem when I get database records through a query DQL
          and then they are changed by another application
        If I repeat the query, Doctrine always return the first value, not the current value of the base

        {code}

        echo "";

        I have a problem when I get database records through a query DQL
          and then they are changed by another application
        If I repeat the query, Doctrine always return the first value, not the current value of the base

        {code}

        echo "";
        {code}

        gabriel sancho made changes -
        Description I have a problem when I get database records through a query DQL
          and then they are changed by another application
        If I repeat the query, Doctrine always return the first value, not the current value of the base

        {code}

        echo "";
        {code}

        I have a problem when I get database records through a query DQL
          and then they are changed by another application
        If I repeat the query, Doctrine always return the first value, not the current value of the base

        {code}
        <?php

        // bootstrap

        $cache = new \Doctrine\Common\Cache\ArrayCache();
        $config = new Doctrine\ORM\Configuration();
        $config->setQueryCacheImpl($cache);
        $conn = array(
        'dbname' => $database_name,
        'user' => $cnx_user,
        'password' => $cnx_pass,
        'host' => $cnx_host,
        'driver' => $cnx_type,
        'charset' => 'utf8',
        'driverOptions' => array( 1002 => "SET NAMES 'utf8'" )
        );

        $em = Doctrine\ORM\EntityManager::create($conn, $config);




        {code}
        {code}
        while(true){
           $dql = "SELECT s from Register s WHERE s.id = 1";
           $query = $em->createQuery($dql);
        // the next line is optional, produces same result
           $query->useResultCache(false);
           $res = $query->getResult();
           $orm = reset($res);
           
           echo " regiter id :".$orm->getId()." field "$orm->getText()."\n";

        }
        {code}

        I run this code in a terminal, and then edit the registry (field text), but the terminal still shows the same result
        Hide
        Benjamin Eberlei added a comment -

        Doctrine uses an IdentityMap pattern which leads to this issue.

        You need to call "EntityManager#clear()" to clean the in memory cache of Doctrine and fetch records from the database again. or call "EntityManager#refresh($entity)"

        Show
        Benjamin Eberlei added a comment - Doctrine uses an IdentityMap pattern which leads to this issue. You need to call "EntityManager#clear()" to clean the in memory cache of Doctrine and fetch records from the database again. or call "EntityManager#refresh($entity)"
        Benjamin Eberlei made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Invalid [ 6 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-2155, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            gabriel sancho
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: