Development

#3306: sfPropelFinder.php.diff

You must first sign up to be able to contribute.

Ticket #3306: sfPropelFinder.php.diff

File sfPropelFinder.php.diff, 1.4 kB (added by jug, 4 months ago)
  • sfPropelFinderPlugin/lib/sfPropelFinder.php

    old new  
    8282    } 
    8383  } 
    8484   
    85   public function updateLatestQuery(
     85  public function updateLatestQuery( $con = null
    8686  { 
    87     $con = Propel::getConnection(); 
     87    if ( is_null($con) ) $con = Propel::getConnection(); 
    8888    if(method_exists($con, 'getLastExecutedQuery')) 
    8989    { 
    9090      $this->latestQuery = $con->getLastExecutedQuery(); 
     
    179179    return $ret; 
    180180  } 
    181181   
     182  public function set( $values, $con = null, $reinitCriteria = true ) 
     183  { 
     184    if ( !is_array($values) ) 
     185      throw new Exception('{sfPropelFinder::set()} First argument is not an array'); 
     186 
     187    $find = $this->getCriteria(); 
     188    if ( count($find->getJoins()) ) 
     189      throw new Exception('{sfPropelFinder::set()} Propel does not support multitable updates, please do not use join'); 
     190 
     191    $set = new Criteria; 
     192    foreach( $values as $columnName => $value ) 
     193    { 
     194      $set->add( $this->getColName($columnName), $value ); 
     195    } 
     196 
     197    if ( is_null($con) ) $con = Propel::getConnection(); 
     198 
     199    $ret = BasePeer::doUpdate( $find, $set, $con ); 
     200    $this->updateLatestQuery( $con ); // 
     201    if($reinitCriteria) 
     202    { 
     203      $this->reinitCriteria(); 
     204    } 
     205 
     206    return $ret; 
     207  } 
     208 
     209 
    182210  // Finder Filters 
    183211   
    184212  /**