Development

Changeset 4940

You must first sign up to be able to contribute.

Changeset 4940

Show
Ignore:
Timestamp:
08/30/07 16:11:28 (2 years ago)
Author:
fabien
Message:

fixed sfPropelData doesn't use connection passed on data load (closes #2149)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/addon/propel/sfPropelData.class.php

    r4910 r4940  
    2121{ 
    2222  protected 
    23     $maps = array(); 
     23    $maps           = array(), 
     24    $deletedClasses = array(), 
     25    $con            = null; 
    2426 
    2527  // symfony load-data (file|dir) 
     
    3739 
    3840    // wrap all database operations in a single transaction 
    39     $con = Propel::getConnection($connectionName); 
     41    $this->con = Propel::getConnection($connectionName); 
    4042    try 
    4143    { 
    42       $con->begin(); 
     44      $this->con->begin(); 
    4345 
    4446      $this->doDeleteCurrentData($fixture_files); 
     
    4648      $this->doLoadData($fixture_files); 
    4749 
    48       $con->commit(); 
     50      $this->con->commit(); 
    4951    } 
    5052    catch (Exception $e) 
    5153    { 
    52       $con->rollback(); 
     54      $this->con->rollback(); 
    5355      throw $e; 
    5456    } 
     
    137139          } 
    138140        } 
    139         $obj->save(); 
     141        $obj->save($this->con); 
    140142 
    141143        // save the id for future reference 
     
    180182      foreach ($classes as $class) 
    181183      { 
    182         $peer_class = trim($class.'Peer'); 
     184        $class = trim($class); 
     185        if (in_array($class, $this->deletedClasses)) 
     186        { 
     187          continue; 
     188        } 
     189 
     190        $peer_class = $class.'Peer'; 
    183191 
    184192        if (!$classPath = sfAutoload::getClassPath($peer_class)) 
     
    189197        require_once($classPath); 
    190198 
    191         call_user_func(array($peer_class, 'doDeleteAll')); 
     199        call_user_func(array($peer_class, 'doDeleteAll'), $this->con); 
     200 
     201        $this->deletedClasses[] = $class; 
    192202      } 
    193203    } 
     
    238248    } 
    239249 
    240     $con = Propel::getConnection($connectionName); 
     250    $this->con = Propel::getConnection($connectionName); 
    241251 
    242252    // get tables 
     
    276286 
    277287      // get db info 
    278       $rs = $con->executeQuery('SELECT * FROM '.constant($tableName.'Peer::TABLE_NAME')); 
     288      $rs = $this->con->executeQuery('SELECT * FROM '.constant($tableName.'Peer::TABLE_NAME')); 
    279289 
    280290      while ($rs->next()) 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.