Uploaded image for project: 'Doctrine 1'
  1. Doctrine 1
  2. DC-827

Custom Doctrine_Query UPDATE statement inside migration scope not working


    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.2
    • Fix Version/s: None
    • Component/s: Migrations
    • Labels:
    • Environment:
      Symfony Framework 1.3
      Zend Server CE 5.0.2 (PHP 5.3.2)
      Apache 2.2
      MySQL 5.1.47
      Windows XP


      I found strange problem in Doctrine migration. I tried to execute custom DQL in migration. Custom query with SELECT statement succeed, but UPDATE query not changed any data in DB and do not returned back any error message. After I tried execute same code in CLI task. Worked well and data in database was updated as I expected. So looks like Doctrine_Query do not works well inside migration scope with UPDATE statement.

      ... or maybe I do something wrong? If did something maybe you have to put in manual how to use custom DQL in migrations correctly. I hope migrations are not only to change structure of tables, but also can be used to change data structure too.

      public function up() {
      $conn = Doctrine_Manager::connection();  	  	
      $brands = Doctrine_Query::create ($conn)
        		->select('b.id, b.name')
        		->from('Brand b')
        		->fetchArray();  // this query worked for me well. I have data
      foreach ($brands as $brand) {
        Doctrine_Query::create ($conn)
        	->set('safe_name', '?', 'some_safe_name')
        	->where('id = ?', $brand['id'])
        	->execute(); // this query was executed but not had any effect on data in DB


        There are no comments yet on this issue.


          • Assignee:
            jwage Jonathan H. Wage
            arnlukas Arnoldas Lukasevicius
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: