Changeset 59


Ignore:
Timestamp:
26.12.2011 14:26:02 (5 months ago)
Author:
benjamin
Message:

ran propel-gen for 1.6.3

Location:
branches/Credentials/app
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • branches/Credentials/app/config/classmap-syscpng-conf.php

    r48 r59  
    11<?php 
    2 // This file generated by Propel 1.6.1 convert-conf target 
     2// This file generated by Propel 1.6.3 convert-conf target 
    33return array ( 
    44  'BaseCredential' => 'propelom/om/BaseCredential.php', 
  • branches/Credentials/app/config/syscpng-conf.php

    r48 r59  
    11<?php 
    2 // This file generated by Propel 1.6.1 convert-conf target 
     2// This file generated by Propel 1.6.3 convert-conf target 
    33// from XML runtime conf file /Users/benjamin/Workspaces/Projekte/SysCP-ng/dev/lib/propel/runtime-conf.xml 
    44$conf = array ( 
     
    1818    'default' => 'syscpng', 
    1919  ), 
    20   'generator_version' => '1.6.1', 
     20  'generator_version' => '1.6.3', 
    2121); 
    2222$conf['classmap'] = include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classmap-syscpng-conf.php'); 
  • branches/Credentials/app/lib/propelom/map/CredentialTableMap.php

    r48 r59  
    5050    public function buildRelations() 
    5151    { 
    52         $this->addRelation('RoleCredential', 'RoleCredential', RelationMap::ONE_TO_MANY, array('id' => 'credential_id', ), null, null); 
    53         $this->addRelation('UserCredential', 'UserCredential', RelationMap::ONE_TO_MANY, array('id' => 'credential_id', ), null, null); 
    54         $this->addRelation('Role', 'Role', RelationMap::MANY_TO_MANY, array(), null, null); 
    55         $this->addRelation('User', 'User', RelationMap::MANY_TO_MANY, array(), null, null); 
     52        $this->addRelation('RoleCredential', 'RoleCredential', RelationMap::ONE_TO_MANY, array('id' => 'credential_id', ), null, null, 'RoleCredentials'); 
     53        $this->addRelation('UserCredential', 'UserCredential', RelationMap::ONE_TO_MANY, array('id' => 'credential_id', ), null, null, 'UserCredentials'); 
     54        $this->addRelation('Role', 'Role', RelationMap::MANY_TO_MANY, array(), null, null, 'Roles'); 
     55        $this->addRelation('User', 'User', RelationMap::MANY_TO_MANY, array(), null, null, 'Users'); 
    5656    } // buildRelations() 
    5757 
  • branches/Credentials/app/lib/propelom/map/RoleTableMap.php

    r48 r59  
    4949    public function buildRelations() 
    5050    { 
    51         $this->addRelation('User', 'User', RelationMap::ONE_TO_MANY, array('id' => 'role_id', ), null, null); 
    52         $this->addRelation('RoleCredential', 'RoleCredential', RelationMap::ONE_TO_MANY, array('id' => 'role_id', ), null, null); 
    53         $this->addRelation('Credential', 'Credential', RelationMap::MANY_TO_MANY, array(), null, null); 
     51        $this->addRelation('User', 'User', RelationMap::ONE_TO_MANY, array('id' => 'role_id', ), null, null, 'Users'); 
     52        $this->addRelation('RoleCredential', 'RoleCredential', RelationMap::ONE_TO_MANY, array('id' => 'role_id', ), null, null, 'RoleCredentials'); 
     53        $this->addRelation('Credential', 'Credential', RelationMap::MANY_TO_MANY, array(), null, null, 'Credentials'); 
    5454    } // buildRelations() 
    5555 
  • branches/Credentials/app/lib/propelom/map/UserTableMap.php

    r48 r59  
    5959    { 
    6060        $this->addRelation('Role', 'Role', RelationMap::MANY_TO_ONE, array('role_id' => 'id', ), null, null); 
    61         $this->addRelation('UserCredential', 'UserCredential', RelationMap::ONE_TO_MANY, array('id' => 'user_id', ), null, null); 
    62         $this->addRelation('Credential', 'Credential', RelationMap::MANY_TO_MANY, array(), null, null); 
     61        $this->addRelation('UserCredential', 'UserCredential', RelationMap::ONE_TO_MANY, array('id' => 'user_id', ), null, null, 'UserCredentials'); 
     62        $this->addRelation('Credential', 'Credential', RelationMap::MANY_TO_MANY, array(), null, null, 'Credentials'); 
    6363    } // buildRelations() 
    6464 
    6565    /** 
    66      *  
     66     * 
    6767     * Gets the list of behaviors registered for this table 
    68      *  
     68     * 
    6969     * @return array Associative array (name => parameters) of behaviors 
    7070     */ 
  • branches/Credentials/app/lib/propelom/om/BaseCredential.php

    r48 r59  
    7878 
    7979    /** 
     80     * An array of objects scheduled for deletion. 
     81     * @var     array 
     82     */ 
     83    protected $rolesScheduledForDeletion = null; 
     84 
     85    /** 
     86     * An array of objects scheduled for deletion. 
     87     * @var     array 
     88     */ 
     89    protected $usersScheduledForDeletion = null; 
     90 
     91    /** 
     92     * An array of objects scheduled for deletion. 
     93     * @var     array 
     94     */ 
     95    protected $roleCredentialsScheduledForDeletion = null; 
     96 
     97    /** 
     98     * An array of objects scheduled for deletion. 
     99     * @var     array 
     100     */ 
     101    protected $userCredentialsScheduledForDeletion = null; 
     102 
     103    /** 
    80104     * Get the [id] column value. 
    81105     *  
     
    302326        $con->beginTransaction(); 
    303327        try { 
     328            $deleteQuery = CredentialQuery::create() 
     329                ->filterByPrimaryKey($this->getPrimaryKey()); 
    304330            $ret = $this->preDelete($con); 
    305331            if ($ret) { 
    306                 CredentialQuery::create() 
    307                     ->filterByPrimaryKey($this->getPrimaryKey()) 
    308                     ->delete($con); 
     332                $deleteQuery->delete($con); 
    309333                $this->postDelete($con); 
    310334                $con->commit(); 
     
    313337                $con->commit(); 
    314338            } 
    315         } catch (PropelException $e) { 
     339        } catch (Exception $e) { 
    316340            $con->rollBack(); 
    317341            throw $e; 
     
    365389            $con->commit(); 
    366390            return $affectedRows; 
    367         } catch (PropelException $e) { 
     391        } catch (Exception $e) { 
    368392            $con->rollBack(); 
    369393            throw $e; 
     
    388412            $this->alreadyInSave = true; 
    389413 
    390             if ($this->isNew() ) { 
    391                 $this->modifiedColumns[] = CredentialPeer::ID; 
    392             } 
    393  
    394             // If this object has been modified, then save it to the database. 
    395             if ($this->isModified()) { 
     414            if ($this->isNew() || $this->isModified()) { 
     415                // persist changes 
    396416                if ($this->isNew()) { 
    397                     $criteria = $this->buildCriteria(); 
    398                     if ($criteria->keyContainsValue(CredentialPeer::ID) ) { 
    399                         throw new PropelException('Cannot insert a value for auto-increment primary key ('.CredentialPeer::ID.')'); 
     417                    $this->doInsert($con); 
     418                } else { 
     419                    $this->doUpdate($con); 
     420                } 
     421                $affectedRows += 1; 
     422                $this->resetModified(); 
     423            } 
     424 
     425            if ($this->rolesScheduledForDeletion !== null) { 
     426                if (!$this->rolesScheduledForDeletion->isEmpty()) { 
     427                    RoleCredentialQuery::create() 
     428                        ->filterByPrimaryKeys($this->rolesScheduledForDeletion->getPrimaryKeys(false)) 
     429                        ->delete($con); 
     430                    $this->rolesScheduledForDeletion = null; 
     431                } 
     432 
     433                foreach ($this->getRoles() as $role) { 
     434                    if ($role->isModified()) { 
     435                        $role->save($con); 
    400436                    } 
    401  
    402                     $pk = BasePeer::doInsert($criteria, $con); 
    403                     $affectedRows = 1; 
    404                     $this->setId($pk);  //[IMV] update autoincrement primary key 
    405                     $this->setNew(false); 
    406                 } else { 
    407                     $affectedRows = CredentialPeer::doUpdate($this, $con); 
    408                 } 
    409  
    410                 $this->resetModified(); // [HL] After being saved an object is no longer 'modified' 
     437                } 
     438            } 
     439 
     440            if ($this->usersScheduledForDeletion !== null) { 
     441                if (!$this->usersScheduledForDeletion->isEmpty()) { 
     442                    UserCredentialQuery::create() 
     443                        ->filterByPrimaryKeys($this->usersScheduledForDeletion->getPrimaryKeys(false)) 
     444                        ->delete($con); 
     445                    $this->usersScheduledForDeletion = null; 
     446                } 
     447 
     448                foreach ($this->getUsers() as $user) { 
     449                    if ($user->isModified()) { 
     450                        $user->save($con); 
     451                    } 
     452                } 
     453            } 
     454 
     455            if ($this->roleCredentialsScheduledForDeletion !== null) { 
     456                if (!$this->roleCredentialsScheduledForDeletion->isEmpty()) { 
     457                    RoleCredentialQuery::create() 
     458                        ->filterByPrimaryKeys($this->roleCredentialsScheduledForDeletion->getPrimaryKeys(false)) 
     459                        ->delete($con); 
     460                    $this->roleCredentialsScheduledForDeletion = null; 
     461                } 
    411462            } 
    412463 
     
    419470            } 
    420471 
     472            if ($this->userCredentialsScheduledForDeletion !== null) { 
     473                if (!$this->userCredentialsScheduledForDeletion->isEmpty()) { 
     474                    UserCredentialQuery::create() 
     475                        ->filterByPrimaryKeys($this->userCredentialsScheduledForDeletion->getPrimaryKeys(false)) 
     476                        ->delete($con); 
     477                    $this->userCredentialsScheduledForDeletion = null; 
     478                } 
     479            } 
     480 
    421481            if ($this->collUserCredentials !== null) { 
    422482                foreach ($this->collUserCredentials as $referrerFK) { 
     
    432492        return $affectedRows; 
    433493    } // doSave() 
     494 
     495    /** 
     496     * Insert the row in the database. 
     497     * 
     498     * @param      PropelPDO $con 
     499     * 
     500     * @throws     PropelException 
     501     * @see        doSave() 
     502     */ 
     503    protected function doInsert(PropelPDO $con) 
     504    { 
     505        $modifiedColumns = array(); 
     506        $index = 0; 
     507 
     508        $this->modifiedColumns[] = CredentialPeer::ID; 
     509        if (null !== $this->id) { 
     510            throw new PropelException('Cannot insert a value for auto-increment primary key (' . CredentialPeer::ID . ')'); 
     511        } 
     512 
     513         // check the columns in natural order for more readable SQL queries 
     514        if ($this->isColumnModified(CredentialPeer::ID)) { 
     515            $modifiedColumns[':p' . $index++]  = '`ID`'; 
     516        } 
     517        if ($this->isColumnModified(CredentialPeer::MODULE)) { 
     518            $modifiedColumns[':p' . $index++]  = '`MODULE`'; 
     519        } 
     520        if ($this->isColumnModified(CredentialPeer::VALUE)) { 
     521            $modifiedColumns[':p' . $index++]  = '`VALUE`'; 
     522        } 
     523 
     524        $sql = sprintf( 
     525            'INSERT INTO `credential` (%s) VALUES (%s)', 
     526            implode(', ', $modifiedColumns), 
     527            implode(', ', array_keys($modifiedColumns)) 
     528        ); 
     529 
     530        try { 
     531            $stmt = $con->prepare($sql); 
     532            foreach ($modifiedColumns as $identifier => $columnName) { 
     533                switch ($columnName) { 
     534                    case '`ID`': 
     535                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); 
     536                        break; 
     537                    case '`MODULE`': 
     538                        $stmt->bindValue($identifier, $this->module, PDO::PARAM_STR); 
     539                        break; 
     540                    case '`VALUE`': 
     541                        $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR); 
     542                        break; 
     543                } 
     544            } 
     545            $stmt->execute(); 
     546        } catch (Exception $e) { 
     547            Propel::log($e->getMessage(), Propel::LOG_ERR); 
     548            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); 
     549        } 
     550 
     551        try { 
     552            $pk = $con->lastInsertId(); 
     553        } catch (Exception $e) { 
     554            throw new PropelException('Unable to get autoincrement id.', $e); 
     555        } 
     556        $this->setId($pk); 
     557 
     558        $this->setNew(false); 
     559    } 
     560 
     561    /** 
     562     * Update the row in the database. 
     563     * 
     564     * @param      PropelPDO $con 
     565     * 
     566     * @see        doSave() 
     567     */ 
     568    protected function doUpdate(PropelPDO $con) 
     569    { 
     570        $selectCriteria = $this->buildPkeyCriteria(); 
     571        $valuesCriteria = $this->buildCriteria(); 
     572        BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); 
     573    } 
    434574 
    435575    /** 
     
    808948    /** 
    809949     * Initializes a collection based on the name of a relation. 
    810      * Avoids crafting an 'init[$relationName]s' method name  
     950     * Avoids crafting an 'init[$relationName]s' method name 
    811951     * that wouldn't work when StandardEnglishPluralizer is used. 
    812952     * 
     
    8931033 
    8941034    /** 
     1035     * Sets a collection of RoleCredential objects related by a one-to-many relationship 
     1036     * to the current object. 
     1037     * It will also schedule objects for deletion based on a diff between old objects (aka persisted) 
     1038     * and new objects from the given Propel collection. 
     1039     * 
     1040     * @param      PropelCollection $roleCredentials A Propel collection. 
     1041     * @param      PropelPDO $con Optional connection object 
     1042     */ 
     1043    public function setRoleCredentials(PropelCollection $roleCredentials, PropelPDO $con = null) 
     1044    { 
     1045        $this->roleCredentialsScheduledForDeletion = $this->getRoleCredentials(new Criteria(), $con)->diff($roleCredentials); 
     1046 
     1047        foreach ($roleCredentials as $roleCredential) { 
     1048            // Fix issue with collection modified by reference 
     1049            if ($roleCredential->isNew()) { 
     1050                $roleCredential->setCredential($this); 
     1051            } 
     1052            $this->addRoleCredential($roleCredential); 
     1053        } 
     1054 
     1055        $this->collRoleCredentials = $roleCredentials; 
     1056    } 
     1057 
     1058    /** 
    8951059     * Returns the number of related RoleCredential objects. 
    8961060     * 
     
    9251089     * 
    9261090     * @param      RoleCredential $l RoleCredential 
    927      * @return     void 
    928      * @throws     PropelException 
     1091     * @return     Credential The current object (for fluent API support) 
    9291092     */ 
    9301093    public function addRoleCredential(RoleCredential $l) 
     
    9341097        } 
    9351098        if (!$this->collRoleCredentials->contains($l)) { // only add it if the **same** object is not already associated 
    936             $this->collRoleCredentials[]= $l; 
    937             $l->setCredential($this); 
    938         } 
     1099            $this->doAddRoleCredential($l); 
     1100        } 
     1101 
     1102        return $this; 
     1103    } 
     1104 
     1105    /** 
     1106     * @param   RoleCredential $roleCredential The roleCredential object to add. 
     1107     */ 
     1108    protected function doAddRoleCredential($roleCredential) 
     1109    { 
     1110        $this->collRoleCredentials[]= $roleCredential; 
     1111        $roleCredential->setCredential($this); 
    9391112    } 
    9401113 
     
    10331206 
    10341207    /** 
     1208     * Sets a collection of UserCredential objects related by a one-to-many relationship 
     1209     * to the current object. 
     1210     * It will also schedule objects for deletion based on a diff between old objects (aka persisted) 
     1211     * and new objects from the given Propel collection. 
     1212     * 
     1213     * @param      PropelCollection $userCredentials A Propel collection. 
     1214     * @param      PropelPDO $con Optional connection object 
     1215     */ 
     1216    public function setUserCredentials(PropelCollection $userCredentials, PropelPDO $con = null) 
     1217    { 
     1218        $this->userCredentialsScheduledForDeletion = $this->getUserCredentials(new Criteria(), $con)->diff($userCredentials); 
     1219 
     1220        foreach ($userCredentials as $userCredential) { 
     1221            // Fix issue with collection modified by reference 
     1222            if ($userCredential->isNew()) { 
     1223                $userCredential->setCredential($this); 
     1224            } 
     1225            $this->addUserCredential($userCredential); 
     1226        } 
     1227 
     1228        $this->collUserCredentials = $userCredentials; 
     1229    } 
     1230 
     1231    /** 
    10351232     * Returns the number of related UserCredential objects. 
    10361233     * 
     
    10651262     * 
    10661263     * @param      UserCredential $l UserCredential 
    1067      * @return     void 
    1068      * @throws     PropelException 
     1264     * @return     Credential The current object (for fluent API support) 
    10691265     */ 
    10701266    public function addUserCredential(UserCredential $l) 
     
    10741270        } 
    10751271        if (!$this->collUserCredentials->contains($l)) { // only add it if the **same** object is not already associated 
    1076             $this->collUserCredentials[]= $l; 
    1077             $l->setCredential($this); 
    1078         } 
     1272            $this->doAddUserCredential($l); 
     1273        } 
     1274 
     1275        return $this; 
     1276    } 
     1277 
     1278    /** 
     1279     * @param   UserCredential $userCredential The userCredential object to add. 
     1280     */ 
     1281    protected function doAddUserCredential($userCredential) 
     1282    { 
     1283        $this->collUserCredentials[]= $userCredential; 
     1284        $userCredential->setCredential($this); 
    10791285    } 
    10801286 
     
    11681374 
    11691375    /** 
     1376     * Sets a collection of Role objects related by a many-to-many relationship 
     1377     * to the current object by way of the role_credential cross-reference table. 
     1378     * It will also schedule objects for deletion based on a diff between old objects (aka persisted) 
     1379     * and new objects from the given Propel collection. 
     1380     * 
     1381     * @param      PropelCollection $roles A Propel collection. 
     1382     * @param      PropelPDO $con Optional connection object 
     1383     */ 
     1384    public function setRoles(PropelCollection $roles, PropelPDO $con = null) 
     1385    { 
     1386        $roleCredentials = RoleCredentialQuery::create() 
     1387            ->filterByRole($roles) 
     1388            ->filterByCredential($this) 
     1389            ->find($con); 
     1390 
     1391        $this->rolesScheduledForDeletion = $this->getRoleCredentials()->diff($roleCredentials); 
     1392        $this->collRoleCredentials = $roleCredentials; 
     1393 
     1394        foreach ($roles as $role) { 
     1395            // Fix issue with collection modified by reference 
     1396            if ($role->isNew()) { 
     1397                $this->doAddRole($role); 
     1398            } else { 
     1399                $this->addRole($role); 
     1400            } 
     1401        } 
     1402 
     1403        $this->collRoles = $roles; 
     1404    } 
     1405 
     1406    /** 
    11701407     * Gets the number of Role objects related by a many-to-many relationship 
    11711408     * to the current object by way of the role_credential cross-reference table. 
     
    12091446        } 
    12101447        if (!$this->collRoles->contains($role)) { // only add it if the **same** object is not already associated 
    1211             $roleCredential = new RoleCredential(); 
    1212             $roleCredential->setRole($role); 
    1213             $this->addRoleCredential($roleCredential); 
     1448            $this->doAddRole($role); 
    12141449 
    12151450            $this->collRoles[]= $role; 
    12161451        } 
     1452    } 
     1453 
     1454    /** 
     1455     * @param   Role $role The role object to add. 
     1456     */ 
     1457    protected function doAddRole($role) 
     1458    { 
     1459        $roleCredential = new RoleCredential(); 
     1460        $roleCredential->setRole($role); 
     1461        $this->addRoleCredential($roleCredential); 
    12171462    } 
    12181463 
     
    12811526 
    12821527    /** 
     1528     * Sets a collection of User objects related by a many-to-many relationship 
     1529     * to the current object by way of the user_credential cross-reference table. 
     1530     * It will also schedule objects for deletion based on a diff between old objects (aka persisted) 
     1531     * and new objects from the given Propel collection. 
     1532     * 
     1533     * @param      PropelCollection $users A Propel collection. 
     1534     * @param      PropelPDO $con Optional connection object 
     1535     */ 
     1536    public function setUsers(PropelCollection $users, PropelPDO $con = null) 
     1537    { 
     1538        $userCredentials = UserCredentialQuery::create() 
     1539            ->filterByUser($users) 
     1540            ->filterByCredential($this) 
     1541            ->find($con); 
     1542 
     1543        $this->usersScheduledForDeletion = $this->getUserCredentials()->diff($userCredentials); 
     1544        $this->collUserCredentials = $userCredentials; 
     1545 
     1546        foreach ($users as $user) { 
     1547            // Fix issue with collection modified by reference 
     1548            if ($user->isNew()) { 
     1549                $this->doAddUser($user); 
     1550            } else { 
     1551                $this->addUser($user); 
     1552            } 
     1553        } 
     1554 
     1555        $this->collUsers = $users; 
     1556    } 
     1557 
     1558    /** 
    12831559     * Gets the number of User objects related by a many-to-many relationship 
    12841560     * to the current object by way of the user_credential cross-reference table. 
     
    13221598        } 
    13231599        if (!$this->collUsers->contains($user)) { // only add it if the **same** object is not already associated 
    1324             $userCredential = new UserCredential(); 
    1325             $userCredential->setUser($user); 
    1326             $this->addUserCredential($userCredential); 
     1600            $this->doAddUser($user); 
    13271601 
    13281602            $this->collUsers[]= $user; 
    13291603        } 
     1604    } 
     1605 
     1606    /** 
     1607     * @param   User $user The user object to add. 
     1608     */ 
     1609    protected function doAddUser($user) 
     1610    { 
     1611        $userCredential = new UserCredential(); 
     1612        $userCredential->setUser($user); 
     1613        $this->addUserCredential($userCredential); 
    13301614    } 
    13311615 
     
    14081692    } 
    14091693 
    1410     /** 
    1411      * Catches calls to virtual methods 
    1412      */ 
    1413     public function __call($name, $params) 
    1414     { 
    1415         if (preg_match('/get(\w+)/', $name, $matches)) { 
    1416             $virtualColumn = $matches[1]; 
    1417             if ($this->hasVirtualColumn($virtualColumn)) { 
    1418                 return $this->getVirtualColumn($virtualColumn); 
    1419             } 
    1420             // no lcfirst in php<5.3... 
    1421             $virtualColumn[0] = strtolower($virtualColumn[0]); 
    1422             if ($this->hasVirtualColumn($virtualColumn)) { 
    1423                 return $this->getVirtualColumn($virtualColumn); 
    1424             } 
    1425         } 
    1426         return parent::__call($name, $params); 
    1427     } 
    1428  
    14291694} // BaseCredential 
  • branches/Credentials/app/lib/propelom/om/BaseCredentialPeer.php

    r48 r59  
    2525    /** the related TableMap class for this table */ 
    2626    const TM_CLASS = 'CredentialTableMap'; 
    27      
     27 
    2828    /** The total number of columns. */ 
    2929    const NUM_COLUMNS = 3; 
     
    4646    /** The default string format for model objects of the related table **/ 
    4747    const DEFAULT_STRING_FORMAT = 'YAML'; 
    48      
     48 
    4949    /** 
    5050     * An identiy map to hold any loaded instances of Credential objects. 
     
    377377 
    378378    /** 
    379      * Retrieves the primary key from the DB resultset row  
     379     * Retrieves the primary key from the DB resultset row 
    380380     * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with 
    381381     * a multi-column primary key, an array of the primary key columns will be returned. 
  • branches/Credentials/app/lib/propelom/om/BaseCredentialQuery.php

    r48 r59  
    4242abstract class BaseCredentialQuery extends ModelCriteria 
    4343{ 
    44  
     44     
    4545    /** 
    4646     * Initializes internal state of BaseCredentialQuery object. 
     
    7979 
    8080    /** 
    81      * Find object by primary key 
    82      * Use instance pooling to avoid a database query if the object exists 
     81     * Find object by primary key. 
     82     * Propel uses the instance pool to skip the database if the object exists. 
     83     * Go fast if the query is untouched. 
     84     * 
    8385     * <code> 
    8486     * $obj  = $c->findPk(12, $con); 
    8587     * </code> 
     88     * 
    8689     * @param     mixed $key Primary key to use for the query 
    8790     * @param     PropelPDO $con an optional connection object 
     
    9194    public function findPk($key, $con = null) 
    9295    { 
    93         if ((null !== ($obj = CredentialPeer::getInstanceFromPool((string) $key))) && $this->getFormatter()->isObjectFormatter()) { 
     96        if ($key === null) { 
     97            return null; 
     98        } 
     99        if ((null !== ($obj = CredentialPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { 
    94100            // the object is alredy in the instance pool 
    95101            return $obj; 
     102        } 
     103        if ($con === null) { 
     104            $con = Propel::getConnection(CredentialPeer::DATABASE_NAME, Propel::CONNECTION_READ); 
     105        } 
     106        $this->basePreSelect($con); 
     107        if ($this->formatter || $this->modelAlias || $this->with || $this->select 
     108         || $this->selectColumns || $this->asColumns || $this->selectModifiers 
     109         || $this->map || $this->having || $this->joins) { 
     110            return $this->findPkComplex($key, $con); 
    96111        } else { 
    97             // the object has not been requested yet, or the formatter is not an object formatter 
    98             $criteria = $this->isKeepQuery() ? clone $this : $this; 
    99             $stmt = $criteria 
    100                 ->filterByPrimaryKey($key) 
    101                 ->getSelectStatement($con); 
    102             return $criteria->getFormatter()->init($criteria)->formatOne($stmt); 
    103         } 
     112            return $this->findPkSimple($key, $con); 
     113        } 
     114    } 
     115 
     116    /** 
     117     * Find object by primary key using raw SQL to go fast. 
     118     * Bypass doSelect() and the object formatter by using generated code. 
     119     * 
     120     * @param     mixed $key Primary key to use for the query 
     121     * @param     PropelPDO $con A connection object 
     122     * 
     123     * @return    Credential A model object, or null if the key is not found 
     124     */ 
     125    protected function findPkSimple($key, $con) 
     126    { 
     127        $sql = 'SELECT `ID`, `MODULE`, `VALUE` FROM `credential` WHERE `ID` = :p0'; 
     128        try { 
     129            $stmt = $con->prepare($sql); 
     130            $stmt->bindValue(':p0', $key, PDO::PARAM_INT); 
     131            $stmt->execute(); 
     132        } catch (Exception $e) { 
     133            Propel::log($e->getMessage(), Propel::LOG_ERR); 
     134            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); 
     135        } 
     136        $obj = null; 
     137        if ($row = $stmt->fetch(PDO::FETCH_NUM)) { 
     138            $obj = new Credential(); 
     139            $obj->hydrate($row); 
     140            CredentialPeer::addInstanceToPool($obj, (string) $row[0]); 
     141        } 
     142        $stmt->closeCursor(); 
     143 
     144        return $obj; 
     145    } 
     146 
     147    /** 
     148     * Find object by primary key. 
     149     * 
     150     * @param     mixed $key Primary key to use for the query 
     151     * @param     PropelPDO $con A connection object 
     152     * 
     153     * @return    Credential|array|mixed the result, formatted by the current formatter 
     154     */ 
     155    protected function findPkComplex($key, $con) 
     156    { 
     157        // As the query uses a PK condition, no limit(1) is necessary. 
     158        $criteria = $this->isKeepQuery() ? clone $this : $this; 
     159        $stmt = $criteria 
     160            ->filterByPrimaryKey($key) 
     161            ->doSelect($con); 
     162        return $criteria->getFormatter()->init($criteria)->formatOne($stmt); 
    104163    } 
    105164 
     
    116175    public function findPks($keys, $con = null) 
    117176    { 
     177        if ($con === null) { 
     178            $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); 
     179        } 
     180        $this->basePreSelect($con); 
    118181        $criteria = $this->isKeepQuery() ? clone $this : $this; 
    119         return $this 
     182        $stmt = $criteria 
    120183            ->filterByPrimaryKeys($keys) 
    121             ->find($con); 
     184            ->doSelect($con); 
     185        return $criteria->getFormatter()->init($criteria)->format($stmt); 
    122186    } 
    123187 
     
    148212    /** 
    149213     * Filter the query on the id column 
    150      *  
     214     * 
    151215     * Example usage: 
    152216     * <code> 
     
    174238    /** 
    175239     * Filter the query on the module column 
    176      *  
     240     * 
    177241     * Example usage: 
    178242     * <code> 
     
    202266    /** 
    203267     * Filter the query on the value column 
    204      *  
     268     * 
    205269     * Example usage: 
    206270     * <code> 
     
    244308            return $this 
    245309                ->useRoleCredentialQuery() 
    246                     ->filterByPrimaryKeys($roleCredential->getPrimaryKeys()) 
     310                ->filterByPrimaryKeys($roleCredential->getPrimaryKeys()) 
    247311                ->endUse(); 
    248312        } else { 
     
    253317    /** 
    254318     * Adds a JOIN clause to the query using the RoleCredential relation 
    255      *  
     319     * 
    256320     * @param     string $relationAlias optional alias for the relation 
    257321     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join' 
     
    263327        $tableMap = $this->getTableMap(); 
    264328        $relationMap = $tableMap->getRelation('RoleCredential'); 
    265          
     329 
    266330        // create a ModelJoin object for this join 
    267331        $join = new ModelJoin(); 
     
    271335            $join->setPreviousJoin($previousJoin); 
    272336        } 
    273          
     337 
    274338        // add the ModelJoin to the current object 
    275339        if($relationAlias) { 
     
    279343            $this->addJoinObject($join, 'RoleCredential'); 
    280344        } 
    281          
     345 
    282346        return $this; 
    283347    } 
     
    287351     * 
    288352     * @see       useQuery() 
    289      *  
     353     * 
    290354     * @param     string $relationAlias optional alias for the relation, 
    291355     *                                   to be used as main alias in the secondary query 
     
    317381            return $this 
    318382                ->useUserCredentialQuery() 
    319                     ->filterByPrimaryKeys($userCredential->getPrimaryKeys()) 
     383                ->filterByPrimaryKeys($userCredential->getPrimaryKeys()) 
    320384                ->endUse(); 
    321385        } else { 
     
    326390    /** 
    327391     * Adds a JOIN clause to the query using the UserCredential relation 
    328      *  
     392     * 
    329393     * @param     string $relationAlias optional alias for the relation 
    330394     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join' 
     
    336400        $tableMap = $this->getTableMap(); 
    337401        $relationMap = $tableMap->getRelation('UserCredential'); 
    338          
     402 
    339403        // create a ModelJoin object for this join 
    340404        $join = new ModelJoin(); 
     
    344408            $join->setPreviousJoin($previousJoin); 
    345409        } 
    346          
     410 
    347411        // add the ModelJoin to the current object 
    348412        if($relationAlias) { 
     
    352416            $this->addJoinObject($join, 'UserCredential'); 
    353417        } 
    354          
     418 
    355419        return $this; 
    356420    } 
     
    360424     * 
    361425     * @see       useQuery() 
    362      *  
     426     * 
    363427     * @param     string $relationAlias optional alias for the relation, 
    364428     *                                   to be used as main alias in the secondary query 
     
    387451        return $this 
    388452            ->useRoleCredentialQuery() 
    389                 ->filterByRole($role, $comparison) 
     453            ->filterByRole($role, $comparison) 
    390454            ->endUse(); 
    391455    } 
    392      
     456 
    393457    /** 
    394458     * Filter the query by a related User object 
     
    404468        return $this 
    405469            ->useUserCredentialQuery() 
    406                 ->filterByUser($user, $comparison) 
     470            ->filterByUser($user, $comparison) 
    407471            ->endUse(); 
    408472    } 
    409      
     473 
    410474    /** 
    411475     * Exclude object from result 
     
    419483        if ($credential) { 
    420484            $this->addUsingAlias(CredentialPeer::ID, $credential->getId(), Criteria::NOT_EQUAL); 
    421       } 
    422        
     485        } 
     486 
    423487        return $this; 
    424488    } 
  • branches/Credentials/app/lib/propelom/om/BaseRole.php

    r48 r59  
    6767 
    6868    /** 
     69     * An array of objects scheduled for deletion. 
     70     * @var     array 
     71     */ 
     72    protected $credentialsScheduledForDeletion = null; 
     73 
     74    /** 
     75     * An array of objects scheduled for deletion. 
     76     * @var     array 
     77     */ 
     78    protected $usersScheduledForDeletion = null; 
     79 
     80    /** 
     81     * An array of objects scheduled for deletion. 
     82     * @var     array 
     83     */ 
     84    protected $roleCredentialsScheduledForDeletion = null; 
     85 
     86    /** 
    6987     * Get the [id] column value. 
    7088     *  
     
    259277        $con->beginTransaction(); 
    260278        try { 
     279            $deleteQuery = RoleQuery::create() 
     280                ->filterByPrimaryKey($this->getPrimaryKey()); 
    261281            $ret = $this->preDelete($con); 
    262282            if ($ret) { 
    263                 RoleQuery::create() 
    264                     ->filterByPrimaryKey($this->getPrimaryKey()) 
    265                     ->delete($con); 
     283                $deleteQuery->delete($con); 
    266284                $this->postDelete($con); 
    267285                $con->commit(); 
     
    270288                $con->commit(); 
    271289            } 
    272         } catch (PropelException $e) { 
     290        } catch (Exception $e) { 
    273291            $con->rollBack(); 
    274292            throw $e; 
     
    322340            $con->commit(); 
    323341            return $affectedRows; 
    324         } catch (PropelException $e) { 
     342        } catch (Exception $e) { 
    325343            $con->rollBack(); 
    326344            throw $e; 
     
    345363            $this->alreadyInSave = true; 
    346364 
    347             if ($this->isNew() ) { 
    348                 $this->modifiedColumns[] = RolePeer::ID; 
    349             } 
    350  
    351             // If this object has been modified, then save it to the database. 
    352             if ($this->isModified()) { 
     365            if ($this->isNew() || $this->isModified()) { 
     366                // persist changes 
    353367                if ($this->isNew()) { 
    354                     $criteria = $this->buildCriteria(); 
    355                     if ($criteria->keyContainsValue(RolePeer::ID) ) { 
    356                         throw new PropelException('Cannot insert a value for auto-increment primary key ('.RolePeer::ID.')'); 
     368                    $this->doInsert($con); 
     369                } else { 
     370                    $this->doUpdate($con); 
     371                } 
     372                $affectedRows += 1; 
     373                $this->resetModified(); 
     374            } 
     375 
     376            if ($this->credentialsScheduledForDeletion !== null) { 
     377                if (!$this->credentialsScheduledForDeletion->isEmpty()) { 
     378                    RoleCredentialQuery::create() 
     379                        ->filterByPrimaryKeys($this->credentialsScheduledForDeletion->getPrimaryKeys(false)) 
     380                        ->delete($con); 
     381                    $this->credentialsScheduledForDeletion = null; 
     382                } 
     383 
     384                foreach ($this->getCredentials() as $credential) { 
     385                    if ($credential->isModified()) { 
     386                        $credential->save($con); 
    357387                    } 
    358  
    359                     $pk = BasePeer::doInsert($criteria, $con); 
    360                     $affectedRows = 1; 
    361                     $this->setId($pk);  //[IMV] update autoincrement primary key 
    362                     $this->setNew(false); 
    363                 } else { 
    364                     $affectedRows = RolePeer::doUpdate($this, $con); 
    365                 } 
    366  
    367                 $this->resetModified(); // [HL] After being saved an object is no longer 'modified' 
     388                } 
     389            } 
     390 
     391            if ($this->usersScheduledForDeletion !== null) { 
     392                if (!$this->usersScheduledForDeletion->isEmpty()) { 
     393                    UserQuery::create() 
     394                        ->filterByPrimaryKeys($this->usersScheduledForDeletion->getPrimaryKeys(false)) 
     395                        ->delete($con); 
     396                    $this->usersScheduledForDeletion = null; 
     397                } 
    368398            } 
    369399 
     
    376406            } 
    377407 
     408            if ($this->roleCredentialsScheduledForDeletion !== null) { 
     409                if (!$this->roleCredentialsScheduledForDeletion->isEmpty()) { 
     410                    RoleCredentialQuery::create() 
     411                        ->filterByPrimaryKeys($this->roleCredentialsScheduledForDeletion->getPrimaryKeys(false)) 
     412                        ->delete($con); 
     413                    $this->roleCredentialsScheduledForDeletion = null; 
     414                } 
     415            } 
     416 
    378417            if ($this->collRoleCredentials !== null) { 
    379418                foreach ($this->collRoleCredentials as $referrerFK) { 
     
    389428        return $affectedRows; 
    390429    } // doSave() 
     430 
     431    /** 
     432     * Insert the row in the database. 
     433     * 
     434     * @param      PropelPDO $con 
     435     * 
     436     * @throws     PropelException 
     437     * @see        doSave() 
     438     */ 
     439    protected function doInsert(PropelPDO $con) 
     440    { 
     441        $modifiedColumns = array(); 
     442        $index = 0; 
     443 
     444        $this->modifiedColumns[] = RolePeer::ID; 
     445        if (null !== $this->id) { 
     446            throw new PropelException('Cannot insert a value for auto-increment primary key (' . RolePeer::ID . ')'); 
     447        } 
     448 
     449         // check the columns in natural order for more readable SQL queries 
     450        if ($this->isColumnModified(RolePeer::ID)) { 
     451            $modifiedColumns[':p' . $index++]  = '`ID`'; 
     452        } 
     453        if ($this->isColumnModified(RolePeer::ROLENAME)) { 
     454            $modifiedColumns[':p' . $index++]  = '`ROLENAME`'; 
     455        } 
     456 
     457        $sql = sprintf( 
     458            'INSERT INTO `role` (%s) VALUES (%s)', 
     459            implode(', ', $modifiedColumns), 
     460            implode(', ', array_keys($modifiedColumns)) 
     461        ); 
     462 
     463        try { 
     464            $stmt = $con->prepare($sql); 
     465            foreach ($modifiedColumns as $identifier => $columnName) { 
     466                switch ($columnName) { 
     467                    case '`ID`': 
     468                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); 
     469                        break; 
     470                    case '`ROLENAME`': 
     471                        $stmt->bindValue($identifier, $this->rolename, PDO::PARAM_STR); 
     472                        break; 
     473                } 
     474            } 
     475            $stmt->execute(); 
     476        } catch (Exception $e) { 
     477            Propel::log($e->getMessage(), Propel::LOG_ERR); 
     478            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); 
     479        } 
     480 
     481        try { 
     482            $pk = $con->lastInsertId(); 
     483        } catch (Exception $e) { 
     484            throw new PropelException('Unable to get autoincrement id.', $e); 
     485        } 
     486        $this->setId($pk); 
     487 
     488        $this->setNew(false); 
     489    } 
     490 
     491    /** 
     492     * Update the row in the database. 
     493     * 
     494     * @param      PropelPDO $con 
     495     * 
     496     * @see        doSave() 
     497     */ 
     498    protected function doUpdate(PropelPDO $con) 
     499    { 
     500        $selectCriteria = $this->buildPkeyCriteria(); 
     501        $valuesCriteria = $this->buildCriteria(); 
     502        BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); 
     503    } 
    391504 
    392505    /** 
     
    755868    /** 
    756869     * Initializes a collection based on the name of a relation. 
    757      * Avoids crafting an 'init[$relationName]s' method name  
     870     * Avoids crafting an 'init[$relationName]s' method name 
    758871     * that wouldn't work when StandardEnglishPluralizer is used. 
    759872     * 
     
    840953 
    841954    /** 
     955     * Sets a collection of User objects related by a one-to-many relationship 
     956     * to the current object. 
     957     * It will also schedule objects for deletion based on a diff between old objects (aka persisted) 
     958     * and new objects from the given Propel collection. 
     959     * 
     960     * @param      PropelCollection $users A Propel collection. 
     961     * @param      PropelPDO $con Optional connection object 
     962     */ 
     963    public function setUsers(PropelCollection $users, PropelPDO $con = null) 
     964    { 
     965        $this->usersScheduledForDeletion = $this->getUsers(new Criteria(), $con)->diff($users); 
     966 
     967        foreach ($users as $user) { 
     968            // Fix issue with collection modified by reference 
     969            if ($user->isNew()) { 
     970                $user->setRole($this); 
     971            } 
     972            $this->addUser($user); 
     973        } 
     974 
     975        $this->collUsers = $users; 
     976    } 
     977 
     978    /** 
    842979     * Returns the number of related User objects. 
    843980     * 
     
    8721009     * 
    8731010     * @param      User $l User 
    874      * @return     void 
    875      * @throws     PropelException 
     1011     * @return     Role The current object (for fluent API support) 
    8761012     */ 
    8771013    public function addUser(User $l) 
     
    8811017        } 
    8821018        if (!$this->collUsers->contains($l)) { // only add it if the **same** object is not already associated 
    883             $this->collUsers[]= $l; 
    884             $l->setRole($this); 
    885         } 
     1019            $this->doAddUser($l); 
     1020        } 
     1021 
     1022        return $this; 
     1023    } 
     1024 
     1025    /** 
     1026     * @param   User $user The user object to add. 
     1027     */ 
     1028    protected function doAddUser($user) 
     1029    { 
     1030        $this->collUsers[]= $user; 
     1031        $user->setRole($this); 
    8861032    } 
    8871033 
     
    9551101 
    9561102    /** 
     1103     * Sets a collection of RoleCredential objects related by a one-to-many relationship 
     1104     * to the current object. 
     1105     * It will also schedule objects for deletion based on a diff between old objects (aka persisted) 
     1106     * and new objects from the given Propel collection. 
     1107     * 
     1108     * @param      PropelCollection $roleCredentials A Propel collection. 
     1109     * @param      PropelPDO $con Optional connection object 
     1110     */ 
     1111    public function setRoleCredentials(PropelCollection $roleCredentials, PropelPDO $con = null) 
     1112    { 
     1113        $this->roleCredentialsScheduledForDeletion = $this->getRoleCredentials(new Criteria(), $con)->diff($roleCredentials); 
     1114 
     1115        foreach ($roleCredentials as $roleCredential) { 
     1116            // Fix issue with collection modified by reference 
     1117            if ($roleCredential->isNew()) { 
     1118                $roleCredential->setRole($this); 
     1119            } 
     1120            $this->addRoleCredential($roleCredential); 
     1121        } 
     1122 
     1123        $this->collRoleCredentials = $roleCredentials; 
     1124    } 
     1125 
     1126    /** 
    9571127     * Returns the number of related RoleCredential objects. 
    9581128     * 
     
    9871157     * 
    9881158     * @param      RoleCredential $l RoleCredential 
    989      * @return     void 
    990      * @throws     PropelException 
     1159     * @return     Role The current object (for fluent API support) 
    9911160     */ 
    9921161    public function addRoleCredential(RoleCredential $l) 
     
    9961165        } 
    9971166        if (!$this->collRoleCredentials->contains($l)) { // only add it if the **same** object is not already associated 
    998             $this->collRoleCredentials[]= $l; 
    999             $l->setRole($this); 
    1000         } 
     1167            $this->doAddRoleCredential($l); 
     1168        } 
     1169 
     1170        return $this; 
     1171    } 
     1172 
     1173    /** 
     1174     * @param   RoleCredential $roleCredential The roleCredential object to add. 
     1175     */ 
     1176    protected function doAddRoleCredential($roleCredential) 
     1177    { 
     1178        $this->collRoleCredentials[]= $roleCredential; 
     1179        $roleCredential->setRole($this); 
    10011180    } 
    10021181 
     
    10901269 
    10911270    /** 
     1271     * Sets a collection of Credential objects related by a many-to-many relationship 
     1272     * to the current object by way of the role_credential cross-reference table. 
     1273     * It will also schedule objects for deletion based on a diff between old objects (aka persisted) 
     1274     * and new objects from the given Propel collection. 
     1275     * 
     1276     * @param      PropelCollection $credentials A Propel collection. 
     1277     * @param      PropelPDO $con Optional connection object 
     1278     */ 
     1279    public function setCredentials(PropelCollection $credentials, PropelPDO $con = null) 
     1280    { 
     1281        $roleCredentials = RoleCredentialQuery::create() 
     1282            ->filterByCredential($credentials) 
     1283            ->filterByRole($this) 
     1284            ->find($con); 
     1285 
     1286        $this->credentialsScheduledForDeletion = $this->getRoleCredentials()->diff($roleCredentials); 
     1287        $this->collRoleCredentials = $roleCredentials; 
     1288 
     1289        foreach ($credentials as $credential) { 
     1290            // Fix issue with collection modified by reference 
     1291            if ($credential->isNew()) { 
     1292                $this->doAddCredential($credential); 
     1293            } else { 
     1294                $this->addCredential($credential); 
     1295            } 
     1296        } 
     1297 
     1298        $this->collCredentials = $credentials; 
     1299    } 
     1300 
     1301    /** 
    10921302     * Gets the number of Credential objects related by a many-to-many relationship 
    10931303     * to the current object by way of the role_credential cross-reference table. 
     
    11311341        } 
    11321342        if (!$this->collCredentials->contains($credential)) { // only add it if the **same** object is not already associated 
    1133             $roleCredential = new RoleCredential(); 
    1134             $roleCredential->setCredential($credential); 
    1135             $this->addRoleCredential($roleCredential); 
     1343            $this->doAddCredential($credential); 
    11361344 
    11371345            $this->collCredentials[]= $credential; 
    11381346        } 
     1347    } 
     1348 
     1349    /** 
     1350     * @param   Credential $credential The credential object to add. 
     1351     */ 
     1352    protected function doAddCredential($credential) 
     1353    { 
     1354        $roleCredential = new RoleCredential(); 
     1355        $roleCredential->setCredential($credential); 
     1356        $this->addRoleCredential($roleCredential); 
    11391357    } 
    11401358 
     
    12071425    } 
    12081426 
    1209     /** 
    1210      * Catches calls to virtual methods 
    1211      */ 
    1212     public function __call($name, $params) 
    1213     { 
    1214         if (preg_match('/get(\w+)/', $name, $matches)) { 
    1215             $virtualColumn = $matches[1]; 
    1216             if ($this->hasVirtualColumn($virtualColumn)) { 
    1217                 return $this->getVirtualColumn($virtualColumn); 
    1218             } 
    1219             // no lcfirst in php<5.3... 
    1220             $virtualColumn[0] = strtolower($virtualColumn[0]); 
    1221             if ($this->hasVirtualColumn($virtualColumn)) { 
    1222                 return $this->getVirtualColumn($virtualColumn); 
    1223             } 
    1224         } 
    1225         return parent::__call($name, $params); 
    1226     } 
    1227  
    12281427} // BaseRole 
  • branches/Credentials/app/lib/propelom/om/BaseRoleCredential.php

    r48 r59  
    265265        $con->beginTransaction(); 
    266266        try { 
     267            $deleteQuery = RoleCredentialQuery::create() 
     268                ->filterByPrimaryKey($this->getPrimaryKey()); 
    267269            $ret = $this->preDelete($con); 
    268270            if ($ret) { 
    269                 RoleCredentialQuery::create() 
    270                     ->filterByPrimaryKey($this->getPrimaryKey()) 
    271                     ->delete($con); 
     271                $deleteQuery->delete($con); 
    272272                $this->postDelete($con); 
    273273                $con->commit(); 
     
    276276                $con->commit(); 
    277277            } 
    278         } catch (PropelException $e) { 
     278        } catch (Exception $e) { 
    279279            $con->rollBack(); 
    280280            throw $e; 
     
    328328            $con->commit(); 
    329329            return $affectedRows; 
    330         } catch (PropelException $e) { 
     330        } catch (Exception $e) { 
    331331            $con->rollBack(); 
    332332            throw $e; 
     
    370370            } 
    371371 
    372  
    373             // If this object has been modified, then save it to the database. 
    374             if ($this->isModified()) { 
     372            if ($this->isNew() || $this->isModified()) { 
     373                // persist changes 
    375374                if ($this->isNew()) { 
    376                     $criteria = $this->buildCriteria(); 
    377                     $pk = BasePeer::doInsert($criteria, $con); 
    378                     $affectedRows += 1; 
    379                     $this->setNew(false); 
     375                    $this->doInsert($con); 
    380376                } else { 
    381                     $affectedRows += RoleCredentialPeer::doUpdate($this, $con); 
     377                    $this->doUpdate($con); 
    382378                } 
    383  
    384                 $this->resetModified(); // [HL] After being saved an object is no longer 'modified' 
     379                $affectedRows += 1; 
     380                $this->resetModified(); 
    385381            } 
    386382 
     
    390386        return $affectedRows; 
    391387    } // doSave() 
     388 
     389    /** 
     390     * Insert the row in the database. 
     391     * 
     392     * @param      PropelPDO $con 
     393     * 
     394     * @throws     PropelException 
     395     * @see        doSave() 
     396     */ 
     397    protected function doInsert(PropelPDO $con) 
     398    { 
     399        $modifiedColumns = array(); 
     400        $index = 0; 
     401 
     402 
     403         // check the columns in natural order for more readable SQL queries 
     404        if ($this->isColumnModified(RoleCredentialPeer::ROLE_ID)) { 
     405            $modifiedColumns[':p' . $index++]  = '`ROLE_ID`'; 
     406        } 
     407        if ($this->isColumnModified(RoleCredentialPeer::CREDENTIAL_ID)) { 
     408            $modifiedColumns[':p' . $index++]  = '`CREDENTIAL_ID`'; 
     409        } 
     410 
     411        $sql = sprintf( 
     412            'INSERT INTO `role_credential` (%s) VALUES (%s)', 
     413            implode(', ', $modifiedColumns), 
     414            implode(', ', array_keys($modifiedColumns)) 
     415        ); 
     416 
     417        try { 
     418            $stmt = $con->prepare($sql); 
     419            foreach ($modifiedColumns as $identifier => $columnName) { 
     420                switch ($columnName) { 
     421                    case '`ROLE_ID`': 
     422                        $stmt->bindValue($identifier, $this->role_id, PDO::PARAM_INT); 
     423                        break; 
     424                    case '`CREDENTIAL_ID`': 
     425                        $stmt->bindValue($identifier, $this->credential_id, PDO::PARAM_INT); 
     426                        break; 
     427                } 
     428            } 
     429            $stmt->execute(); 
     430        } catch (Exception $e) { 
     431            Propel::log($e->getMessage(), Propel::LOG_ERR); 
     432            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); 
     433        } 
     434 
     435        $this->setNew(false); 
     436    } 
     437 
     438    /** 
     439     * Update the row in the database. 
     440     * 
     441     * @param      PropelPDO $con 
     442     * 
     443     * @see        doSave() 
     444     */ 
     445    protected function doUpdate(PropelPDO $con) 
     446    { 
     447        $selectCriteria = $this->buildPkeyCriteria(); 
     448        $valuesCriteria = $this->buildCriteria(); 
     449        BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); 
     450    } 
    392451 
    393452    /** 
     
    883942    } 
    884943 
    885     /** 
    886      * Catches calls to virtual methods 
    887      */ 
    888     public function __call($name, $params) 
    889     { 
    890         if (preg_match('/get(\w+)/', $name, $matches)) { 
    891             $virtualColumn = $matches[1]; 
    892             if ($this->hasVirtualColumn($virtualColumn)) { 
    893                 return $this->getVirtualColumn($virtualColumn); 
    894             } 
    895             // no lcfirst in php<5.3... 
    896             $virtualColumn[0] = strtolower($virtualColumn[0]); 
    897             if ($this->hasVirtualColumn($virtualColumn)) { 
    898                 return $this->getVirtualColumn($virtualColumn); 
    899             } 
    900         } 
    901         return parent::__call($name, $params); 
    902     } 
    903  
    904944} // BaseRoleCredential 
  • branches/Credentials/app/lib/propelom/om/BaseRoleCredentialPeer.php

    r48 r59  
    2525    /** the related TableMap class for this table */ 
    2626    const TM_CLASS = 'RoleCredentialTableMap'; 
    27      
     27 
    2828    /** The total number of columns. */ 
    2929    const NUM_COLUMNS = 2; 
     
    4343    /** The default string format for model objects of the related table **/ 
    4444    const DEFAULT_STRING_FORMAT = 'YAML'; 
    45      
     45 
    4646    /** 
    4747     * An identiy map to hold any loaded instances of RoleCredential objects. 
     
    372372 
    373373    /** 
    374      * Retrieves the primary key from the DB resultset row  
     374     * Retrieves the primary key from the DB resultset row 
    375375     * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with 
    376376     * a multi-column primary key, an array of the primary key columns will be returned. 
     
    469469            RoleCredentialPeer::addSelectColumns($criteria); 
    470470        } 
    471          
     471 
    472472        $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count 
    473          
     473 
    474474        // Set the correct dbName 
    475475        $criteria->setDbName(self::DATABASE_NAME); 
     
    519519            RoleCredentialPeer::addSelectColumns($criteria); 
    520520        } 
    521          
     521 
    522522        $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count 
    523          
     523 
    524524        // Set the correct dbName 
    525525        $criteria->setDbName(self::DATABASE_NAME); 
     
    701701            RoleCredentialPeer::addSelectColumns($criteria); 
    702702        } 
    703          
     703 
    704704        $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count 
    705          
     705 
    706706        // Set the correct dbName 
    707707        $criteria->setDbName(self::DATABASE_NAME); 
     
    836836        // tables go into the FROM clause. 
    837837        $criteria->setPrimaryTableName(RoleCredentialPeer::TABLE_NAME); 
    838          
     838 
    839839        if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { 
    840840            $criteria->setDistinct(); 
     
    844844            RoleCredentialPeer::addSelectColumns($criteria); 
    845845        } 
    846          
     846 
    847847        $criteria->clearOrderByColumns(); // ORDER BY should not affect count 
    848          
     848 
    849849        // Set the correct dbName 
    850850        $criteria->setDbName(self::DATABASE_NAME); 
     
    886886        // tables go into the FROM clause. 
    887887        $criteria->setPrimaryTableName(RoleCredentialPeer::TABLE_NAME); 
    888          
     888 
    889889        if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { 
    890890            $criteria->setDistinct(); 
     
    894894            RoleCredentialPeer::addSelectColumns($criteria); 
    895895        } 
    896          
     896 
    897897        $criteria->clearOrderByColumns(); // ORDER BY should not affect count 
    898          
     898 
    899899        // Set the correct dbName 
    900900        $criteria->setDbName(self::DATABASE_NAME); 
  • branches/Credentials/app/lib/propelom/om/BaseRoleCredentialQuery.php

    r48 r59  
    3838abstract class BaseRoleCredentialQuery extends ModelCriteria 
    3939{ 
    40  
     40     
    4141    /** 
    4242     * Initializes internal state of BaseRoleCredentialQuery object. 
     
    7575 
    7676    /** 
    77      * Find object by primary key 
     77     * Find object by primary key. 
     78     * Propel uses the instance pool to skip the database if the object exists. 
     79     * Go fast if the query is untouched. 
     80     * 
    7881     * <code> 
    7982     * $obj = $c->findPk(array(12, 34), $con); 
    8083     * </code> 
     84     * 
    8185     * @param     array[$role_id, $credential_id] $key Primary key to use for the query 
    8286     * @param     PropelPDO $con an optional connection object 
     
    8690    public function findPk($key, $con = null) 
    8791    { 
    88         if ((null !== ($obj = RoleCredentialPeer::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && $this->getFormatter()->isObjectFormatter()) { 
     92        if ($key === null) { 
     93            return null; 
     94        } 
     95        if ((null !== ($obj = RoleCredentialPeer::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { 
    8996            // the object is alredy in the instance pool 
    9097            return $obj; 
     98        } 
     99        if ($con === null) { 
     100            $con = Propel::getConnection(RoleCredentialPeer::DATABASE_NAME, Propel::CONNECTION_READ); 
     101        } 
     102        $this->basePreSelect($con); 
     103        if ($this->formatter || $this->modelAlias || $this->with || $this->select 
     104         || $this->selectColumns || $this->asColumns || $this->selectModifiers 
     105         || $this->map || $this->having || $this->joins) { 
     106            return $this->findPkComplex($key, $con); 
    91107        } else { 
    92             // the object has not been requested yet, or the formatter is not an object formatter 
    93             $criteria = $this->isKeepQuery() ? clone $this : $this; 
    94             $stmt = $criteria 
    95                 ->filterByPrimaryKey($key) 
    96                 ->getSelectStatement($con); 
    97             return $criteria->getFormatter()->init($criteria)->formatOne($stmt); 
    98         } 
     108            return $this->findPkSimple($key, $con); 
     109        } 
     110    } 
     111 
     112    /** 
     113     * Find object by primary key using raw SQL to go fast. 
     114     * Bypass doSelect() and the object formatter by using generated code. 
     115     * 
     116     * @param     mixed $key Primary key to use for the query 
     117     * @param     PropelPDO $con A connection object 
     118     * 
     119     * @return    RoleCredential A model object, or null if the key is not found 
     120     */ 
     121    protected function findPkSimple($key, $con) 
     122    { 
     123        $sql = 'SELECT `ROLE_ID`, `CREDENTIAL_ID` FROM `role_credential` WHERE `ROLE_ID` = :p0 AND `CREDENTIAL_ID` = :p1'; 
     124        try { 
     125            $stmt = $con->prepare($sql); 
     126            $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); 
     127            $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT); 
     128            $stmt->execute(); 
     129        } catch (Exception $e) { 
     130            Propel::log($e->getMessage(), Propel::LOG_ERR); 
     131            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); 
     132        } 
     133        $obj = null; 
     134        if ($row = $stmt->fetch(PDO::FETCH_NUM)) { 
     135            $obj = new RoleCredential(); 
     136            $obj->hydrate($row); 
     137            RoleCredentialPeer::addInstanceToPool($obj, serialize(array((string) $row[0], (string) $row[1]))); 
     138        } 
     139        $stmt->closeCursor(); 
     140 
     141        return $obj; 
     142    } 
     143 
     144    /** 
     145     * Find object by primary key. 
     146     * 
     147     * @param     mixed $key Primary key to use for the query 
     148     * @param     PropelPDO $con A connection object 
     149     * 
     150     * @return    RoleCredential|array|mixed the result, formatted by the current formatter 
     151     */ 
     152    protected function findPkComplex($key, $con) 
     153    { 
     154        // As the query uses a PK condition, no limit(1) is necessary. 
     155        $criteria = $this->isKeepQuery() ? clone $this : $this; 
     156        $stmt = $criteria 
     157            ->filterByPrimaryKey($key) 
     158            ->doSelect($con); 
     159        return $criteria->getFormatter()->init($criteria)->formatOne($stmt); 
    99160    } 
    100161 
     
    111172    public function findPks($keys, $con = null) 
    112173    { 
     174        if ($con === null) { 
     175            $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); 
     176        } 
     177        $this->basePreSelect($con); 
    113178        $criteria = $this->isKeepQuery() ? clone $this : $this; 
    114         return $this 
     179        $stmt = $criteria 
    115180            ->filterByPrimaryKeys($keys) 
    116             ->find($con); 
     181            ->doSelect($con); 
     182        return $criteria->getFormatter()->init($criteria)->format($stmt); 
    117183    } 
    118184 
     
    128194        $this->addUsingAlias(RoleCredentialPeer::ROLE_ID, $key[0], Criteria::EQUAL); 
    129195        $this->addUsingAlias(RoleCredentialPeer::CREDENTIAL_ID, $key[1], Criteria::EQUAL); 
    130          
     196 
    131197        return $this; 
    132198    } 
     
    150216            $this->addOr($cton0); 
    151217        } 
    152          
     218 
    153219        return $this; 
    154220    } 
     
    156222    /** 
    157223     * Filter the query on the role_id column 
    158      *  
     224     * 
    159225     * Example usage: 
    160226     * <code> 
     
    184250    /** 
    185251     * Filter the query on the credential_id column 
    186      *  
     252     * 
    187253     * Example usage: 
    188254     * <code> 
     
    236302    /** 
    237303     * Adds a JOIN clause to the query using the Role relation 
    238      *  
     304     * 
    239305     * @param     string $relationAlias optional alias for the relation 
    240306     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join' 
     
    246312        $tableMap = $this->getTableMap(); 
    247313        $relationMap = $tableMap->getRelation('Role'); 
    248          
     314 
    249315        // create a ModelJoin object for this join 
    250316        $join = new ModelJoin(); 
     
    254320            $join->setPreviousJoin($previousJoin); 
    255321        } 
    256          
     322 
    257323        // add the ModelJoin to the current object 
    258324        if($relationAlias) { 
     
    262328            $this->addJoinObject($join, 'Role'); 
    263329        } 
    264          
     330 
    265331        return $this; 
    266332    } 
     
    270336     * 
    271337     * @see       useQuery() 
    272      *  
     338     * 
    273339     * @param     string $relationAlias optional alias for the relation, 
    274340     *                                   to be used as main alias in the secondary query 
     
    310376    /** 
    311377     * Adds a JOIN clause to the query using the Credential relation 
    312      *  
     378     * 
    313379     * @param     string $relationAlias optional alias for the relation 
    314380     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join' 
     
    320386        $tableMap = $this->getTableMap(); 
    321387        $relationMap = $tableMap->getRelation('Credential'); 
    322          
     388 
    323389        // create a ModelJoin object for this join 
    324390        $join = new ModelJoin(); 
     
    328394            $join->setPreviousJoin($previousJoin); 
    329395        } 
    330          
     396 
    331397        // add the ModelJoin to the current object 
    332398        if($relationAlias) { 
     
    336402            $this->addJoinObject($join, 'Credential'); 
    337403        } 
    338          
     404 
    339405        return $this; 
    340406    } 
     
    344410     * 
    345411     * @see       useQuery() 
    346      *  
     412     * 
    347413     * @param     string $relationAlias optional alias for the relation, 
    348414     *                                   to be used as main alias in the secondary query 
     
    371437            $this->addCond('pruneCond1', $this->getAliasedColName(RoleCredentialPeer::CREDENTIAL_ID), $roleCredential->getCredentialId(), Criteria::NOT_EQUAL); 
    372438            $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); 
    373       } 
    374        
     439        } 
     440 
    375441        return $this; 
    376442    } 
  • branches/Credentials/app/lib/propelom/om/BaseRolePeer.php

    r48 r59  
    2525    /** the related TableMap class for this table */ 
    2626    const TM_CLASS = 'RoleTableMap'; 
    27      
     27 
    2828    /** The total number of columns. */ 
    2929    const NUM_COLUMNS = 2; 
     
    4343    /** The default string format for model objects of the related table **/ 
    4444    const DEFAULT_STRING_FORMAT = 'YAML'; 
    45      
     45 
    4646    /** 
    4747     * An identiy map to hold any loaded instances of Role objects. 
     
    372372 
    373373    /** 
    374      * Retrieves the primary key from the DB resultset row  
     374     * Retrieves the primary key from the DB resultset row 
    375375     * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with 
    376376     * a multi-column primary key, an array of the primary key columns will be returned. 
  • branches/Credentials/app/lib/propelom/om/BaseRoleQuery.php

    r48 r59  
    3838abstract class BaseRoleQuery extends ModelCriteria 
    3939{ 
    40  
     40     
    4141    /** 
    4242     * Initializes internal state of BaseRoleQuery object. 
     
    7575 
    7676    /** 
    77      * Find object by primary key 
    78      * Use instance pooling to avoid a database query if the object exists 
     77     * Find object by primary key. 
     78     * Propel uses the instance pool to skip the database if the object exists. 
     79     * Go fast if the query is untouched. 
     80     * 
    7981     * <code> 
    8082     * $obj  = $c->findPk(12, $con); 
    8183     * </code> 
     84     * 
    8285     * @param     mixed $key Primary key to use for the query 
    8386     * @param     PropelPDO $con an optional connection object 
     
    8790    public function findPk($key, $con = null) 
    8891    { 
    89         if ((null !== ($obj = RolePeer::getInstanceFromPool((string) $key))) && $this->getFormatter()->isObjectFormatter()) { 
     92        if ($key === null) { 
     93            return null; 
     94        } 
     95        if ((null !== ($obj = RolePeer::getInstanceFromPool((string) $key))) && !$this->formatter) { 
    9096            // the object is alredy in the instance pool 
    9197            return $obj; 
     98        } 
     99        if ($con === null) { 
     100            $con = Propel::getConnection(RolePeer::DATABASE_NAME, Propel::CONNECTION_READ); 
     101        } 
     102        $this->basePreSelect($con); 
     103        if ($this->formatter || $this->modelAlias || $this->with || $this->select 
     104         || $this->selectColumns || $this->asColumns || $this->selectModifiers 
     105         || $this->map || $this->having || $this->joins) { 
     106            return $this->findPkComplex($key, $con); 
    92107        } else { 
    93             // the object has not been requested yet, or the formatter is not an object formatter 
    94             $criteria = $this->isKeepQuery() ? clone $this : $this; 
    95             $stmt = $criteria 
    96                 ->filterByPrimaryKey($key) 
    97                 ->getSelectStatement($con); 
    98             return $criteria->getFormatter()->init($criteria)->formatOne($stmt); 
    99         } 
     108            return $this->findPkSimple($key, $con); 
     109        } 
     110    } 
     111 
     112    /** 
     113     * Find object by primary key using raw SQL to go fast. 
     114     * Bypass doSelect() and the object formatter by using generated code. 
     115     * 
     116     * @param     mixed $key Primary key to use for the query 
     117     * @param     PropelPDO $con A connection object 
     118     * 
     119     * @return    Role A model object, or null if the key is not found 
     120     */ 
     121    protected function findPkSimple($key, $con) 
     122    { 
     123        $sql = 'SELECT `ID`, `ROLENAME` FROM `role` WHERE `ID` = :p0'; 
     124        try { 
     125            $stmt = $con->prepare($sql); 
     126            $stmt->bindValue(':p0', $key, PDO::PARAM_INT); 
     127            $stmt->execute(); 
     128        } catch (Exception $e) { 
     129            Propel::log($e->getMessage(), Propel::LOG_ERR); 
     130            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); 
     131        } 
     132        $obj = null; 
     133        if ($row = $stmt->fetch(PDO::FETCH_NUM)) { 
     134            $obj = new Role(); 
     135            $obj->hydrate($row); 
     136            RolePeer::addInstanceToPool($obj, (string) $row[0]); 
     137        } 
     138        $stmt->closeCursor(); 
     139 
     140        return $obj; 
     141    } 
     142 
     143    /** 
     144     * Find object by primary key. 
     145     * 
     146     * @param     mixed $key Primary key to use for the query 
     147     * @param     PropelPDO $con A connection object 
     148     * 
     149     * @return    Role|array|mixed the result, formatted by the current formatter 
     150     */ 
     151    protected function findPkComplex($key, $con) 
     152    { 
     153        // As the query uses a PK condition, no limit(1) is necessary. 
     154        $criteria = $this->isKeepQuery() ? clone $this : $this; 
     155        $stmt = $criteria 
     156            ->filterByPrimaryKey($key) 
     157            ->doSelect($con); 
     158        return $criteria->getFormatter()->init($criteria)->formatOne($stmt); 
    100159    } 
    101160 
     
    112171    public function findPks($keys, $con = null) 
    113172    { 
     173        if ($con === null) { 
     174            $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); 
     175        } 
     176        $this->basePreSelect($con); 
    114177        $criteria = $this->isKeepQuery() ? clone $this : $this; 
    115         return $this 
     178        $stmt = $criteria 
    116179            ->filterByPrimaryKeys($keys) 
    117             ->find($con); 
     180            ->doSelect($con); 
     181        return $criteria->getFormatter()->init($criteria)->format($stmt); 
    118182    } 
    119183 
     
    144208    /** 
    145209     * Filter the query on the id column 
    146      *  
     210     * 
    147211     * Example usage: 
    148212     * <code> 
     
    170234    /** 
    171235     * Filter the query on the rolename column 
    172      *  
     236     * 
    173237     * Example usage: 
    174238     * <code> 
     
    212276            return $this 
    213277                ->useUserQuery() 
    214                     ->filterByPrimaryKeys($user->getPrimaryKeys()) 
     278                ->filterByPrimaryKeys($user->getPrimaryKeys()) 
    215279                ->endUse(); 
    216280        } else { 
     
    221285    /** 
    222286     * Adds a JOIN clause to the query using the User relation 
    223      *  
     287     * 
    224288     * @param     string $relationAlias optional alias for the relation 
    225289     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join' 
     
    231295        $tableMap = $this->getTableMap(); 
    232296        $relationMap = $tableMap->getRelation('User'); 
    233          
     297 
    234298        // create a ModelJoin object for this join 
    235299        $join = new ModelJoin(); 
     
    239303            $join->setPreviousJoin($previousJoin); 
    240304        } 
    241          
     305 
    242306        // add the ModelJoin to the current object 
    243307        if($relationAlias) { 
     
    247311            $this->addJoinObject($join, 'User'); 
    248312        } 
    249          
     313 
    250314        return $this; 
    251315    } 
     
    255319     * 
    256320     * @see       useQuery() 
    257      *  
     321     * 
    258322     * @param     string $relationAlias optional alias for the relation, 
    259323     *                                   to be used as main alias in the secondary query 
     
    285349            return $this 
    286350                ->useRoleCredentialQuery() 
    287                     ->filterByPrimaryKeys($roleCredential->getPrimaryKeys()) 
     351                ->filterByPrimaryKeys($roleCredential->getPrimaryKeys()) 
    288352                ->endUse(); 
    289353        } else { 
     
    294358    /** 
    295359     * Adds a JOIN clause to the query using the RoleCredential relation 
    296      *  
     360     * 
    297361     * @param     string $relationAlias optional alias for the relation 
    298362     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join' 
     
    304368        $tableMap = $this->getTableMap(); 
    305369        $relationMap = $tableMap->getRelation('RoleCredential'); 
    306          
     370 
    307371        // create a ModelJoin object for this join 
    308372        $join = new ModelJoin(); 
     
    312376            $join->setPreviousJoin($previousJoin); 
    313377        } 
    314          
     378 
    315379        // add the ModelJoin to the current object 
    316380        if($relationAlias) { 
     
    320384            $this->addJoinObject($join, 'RoleCredential'); 
    321385        } 
    322          
     386 
    323387        return $this; 
    324388    } 
     
    328392     * 
    329393     * @see       useQuery() 
    330      *  
     394     * 
    331395     * @param     string $relationAlias optional alias for the relation, 
    332396     *                                   to be used as main alias in the secondary query 
     
    355419        return $this 
    356420            ->useRoleCredentialQuery() 
    357                 ->filterByCredential($credential, $comparison) 
     421            ->filterByCredential($credential, $comparison) 
    358422            ->endUse(); 
    359423    } 
    360      
     424 
    361425    /** 
    362426     * Exclude object from result 
     
    370434        if ($role) { 
    371435            $this->addUsingAlias(RolePeer::ID, $role->getId(), Criteria::NOT_EQUAL); 
    372       } 
    373        
     436        } 
     437 
    374438        return $this; 
    375439    } 
  • branches/Credentials/app/lib/propelom/om/BaseUser.php

    r48 r59  
    143143 
    144144    /** 
     145     * An array of objects scheduled for deletion. 
     146     * @var     array 
     147     */ 
     148    protected $credentialsScheduledForDeletion = null; 
     149 
     150    /** 
     151     * An array of objects scheduled for deletion. 
     152     * @var     array 
     153     */ 
     154    protected $userCredentialsScheduledForDeletion = null; 
     155 
     156    /** 
    145157     * Applies default values to this object. 
    146158     * This method should be called from the object's constructor (or 
     
    437449        } 
    438450 
    439         if ($this->login_failure_count !== $v || $this->isNew()) { 
     451        if ($this->login_failure_count !== $v) { 
    440452            $this->login_failure_count = $v; 
    441453            $this->modifiedColumns[] = UserPeer::LOGIN_FAILURE_COUNT; 
     
    675687        $con->beginTransaction(); 
    676688        try { 
     689            $deleteQuery = UserQuery::create() 
     690                ->filterByPrimaryKey($this->getPrimaryKey()); 
    677691            $ret = $this->preDelete($con); 
    678692            // nested_set behavior 
     
    686700 
    687701            if ($ret) { 
    688                 UserQuery::create() 
    689                     ->filterByPrimaryKey($this->getPrimaryKey()) 
    690                     ->delete($con); 
     702                $deleteQuery->delete($con); 
    691703                $this->postDelete($con); 
    692704                // nested_set behavior 
     
    701713                $con->commit(); 
    702714            } 
    703         } catch (PropelException $e) { 
     715        } catch (Exception $e) { 
    704716            $con->rollBack(); 
    705717            throw $e; 
     
    764776            $con->commit(); 
    765777            return $affectedRows; 
    766         } catch (PropelException $e) { 
     778        } catch (Exception $e) { 
    767779            $con->rollBack(); 
    768780            throw $e; 
     
    799811            } 
    800812 
    801             if ($this->isNew() ) { 
    802                 $this->modifiedColumns[] = UserPeer::ID; 
    803             } 
    804  
    805             // If this object has been modified, then save it to the database. 
    806             if ($this->isModified()) { 
     813            if ($this->isNew() || $this->isModified()) { 
     814                // persist changes 
    807815                if ($this->isNew()) { 
    808                     $criteria = $this->buildCriteria(); 
    809                     if ($criteria->keyContainsValue(UserPeer::ID) ) { 
    810                         throw new PropelException('Cannot insert a value for auto-increment primary key ('.UserPeer::ID.')'); 
     816                    $this->doInsert($con); 
     817                } else { 
     818                    $this->doUpdate($con); 
     819                } 
     820                $affectedRows += 1; 
     821                $this->resetModified(); 
     822            } 
     823 
     824            if ($this->credentialsScheduledForDeletion !== null) { 
     825                if (!$this->credentialsScheduledForDeletion->isEmpty()) { 
     826                    UserCredentialQuery::create() 
     827                        ->filterByPrimaryKeys($this->credentialsScheduledForDeletion->getPrimaryKeys(false)) 
     828                        ->delete($con); 
     829                    $this->credentialsScheduledForDeletion = null; 
     830                } 
     831 
     832                foreach ($this->getCredentials() as $credential) { 
     833                    if ($credential->isModified()) { 
     834                        $credential->save($con); 
    811835                    } 
    812  
    813                     $pk = BasePeer::doInsert($criteria, $con); 
    814                     $affectedRows += 1; 
    815                     $this->setId($pk);  //[IMV] update autoincrement primary key 
    816                     $this->setNew(false); 
    817                 } else { 
    818                     $affectedRows += UserPeer::doUpdate($this, $con); 
    819836                } 
    820  
    821                 $this->resetModified(); // [HL] After being saved an object is no longer 'modified' 
     837            } 
     838 
     839            if ($this->userCredentialsScheduledForDeletion !== null) { 
     840                if (!$this->userCredentialsScheduledForDeletion->isEmpty()) { 
     841                    UserCredentialQuery::create() 
     842                        ->filterByPrimaryKeys($this->userCredentialsScheduledForDeletion->getPrimaryKeys(false)) 
     843                        ->delete($con); 
     844                    $this->userCredentialsScheduledForDeletion = null; 
     845                } 
    822846            } 
    823847 
     
    835859        return $affectedRows; 
    836860    } // doSave() 
     861 
     862    /** 
     863     * Insert the row in the database. 
     864     * 
     865     * @param      PropelPDO $con 
     866     * 
     867     * @throws     PropelException 
     868     * @see        doSave() 
     869     */ 
     870    protected function doInsert(PropelPDO $con) 
     871    { 
     872        $modifiedColumns = array(); 
     873        $index = 0; 
     874 
     875        $this->modifiedColumns[] = UserPeer::ID; 
     876        if (null !== $this->id) { 
     877            throw new PropelException('Cannot insert a value for auto-increment primary key (' . UserPeer::ID . ')'); 
     878        } 
     879 
     880         // check the columns in natural order for more readable SQL queries 
     881        if ($this->isColumnModified(UserPeer::ID)) { 
     882            $modifiedColumns[':p' . $index++]  = '`ID`'; 
     883        } 
     884        if ($this->isColumnModified(UserPeer::USERNAME)) { 
     885            $modifiedColumns[':p' . $index++]  = '`USERNAME`'; 
     886        } 
     887        if ($this->isColumnModified(UserPeer::EMAIL)) { 
     888            $modifiedColumns[':p' . $index++]  = '`EMAIL`'; 
     889        } 
     890        if ($this->isColumnModified(UserPeer::SALT)) { 
     891            $modifiedColumns[':p' . $index++]  = '`SALT`'; 
     892        } 
     893        if ($this->isColumnModified(UserPeer::PASSWORD)) { 
     894            $modifiedColumns[':p' . $index++]  = '`PASSWORD`'; 
     895        } 
     896        if ($this->isColumnModified(UserPeer::ROLE_ID)) { 
     897            $modifiedColumns[':p' . $index++]  = '`ROLE_ID`'; 
     898        } 
     899        if ($this->isColumnModified(UserPeer::LOGIN_FAILURE_COUNT)) { 
     900            $modifiedColumns[':p' . $index++]  = '`LOGIN_FAILURE_COUNT`'; 
     901        } 
     902        if ($this->isColumnModified(UserPeer::LOGIN_FAILURE_DATE)) { 
     903            $modifiedColumns[':p' . $index++]  = '`LOGIN_FAILURE_DATE`'; 
     904        } 
     905        if ($this->isColumnModified(UserPeer::TREE_LEFT)) { 
     906            $modifiedColumns[':p' . $index++]  = '`TREE_LEFT`'; 
     907        } 
     908        if ($this->isColumnModified(UserPeer::TREE_RIGHT)) { 
     909            $modifiedColumns[':p' . $index++]  = '`TREE_RIGHT`'; 
     910        } 
     911        if ($this->isColumnModified(UserPeer::TREE_LEVEL)) { 
     912            $modifiedColumns[':p' . $index++]  = '`TREE_LEVEL`'; 
     913        } 
     914 
     915        $sql = sprintf( 
     916            'INSERT INTO `user` (%s) VALUES (%s)', 
     917            implode(', ', $modifiedColumns), 
     918            implode(', ', array_keys($modifiedColumns)) 
     919        ); 
     920 
     921        try { 
     922            $stmt = $con->prepare($sql); 
     923            foreach ($modifiedColumns as $identifier => $columnName) { 
     924                switch ($columnName) { 
     925                    case '`ID`': 
     926                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); 
     927                        break; 
     928                    case '`USERNAME`': 
     929                        $stmt->bindValue($identifier, $this->username, PDO::PARAM_STR); 
     930                        break; 
     931                    case '`EMAIL`': 
     932                        $stmt->bindValue($identifier, $this->email, PDO::PARAM_STR); 
     933                        break; 
     934                    case '`SALT`': 
     935                        $stmt->bindValue($identifier, $this->salt, PDO::PARAM_STR); 
     936                        break; 
     937                    case '`PASSWORD`': 
     938                        $stmt->bindValue($identifier, $this->password, PDO::PARAM_STR); 
     939                        break; 
     940                    case '`ROLE_ID`': 
     941                        $stmt->bindValue($identifier, $this->role_id, PDO::PARAM_INT); 
     942                        break; 
     943                    case '`LOGIN_FAILURE_COUNT`': 
     944                        $stmt->bindValue($identifier, $this->login_failure_count, PDO::PARAM_INT); 
     945                        break; 
     946                    case '`LOGIN_FAILURE_DATE`': 
     947                        $stmt->bindValue($identifier, $this->login_failure_date, PDO::PARAM_STR); 
     948                        break; 
     949                    case '`TREE_LEFT`': 
     950                        $stmt->bindValue($identifier, $this->tree_left, PDO::PARAM_INT); 
     951                        break; 
     952                    case '`TREE_RIGHT`': 
     953                        $stmt->bindValue($identifier, $this->tree_right, PDO::PARAM_INT); 
     954                        break; 
     955                    case '`TREE_LEVEL`': 
     956                        $stmt->bindValue($identifier, $this->tree_level, PDO::PARAM_INT); 
     957                        break; 
     958                } 
     959            } 
     960            $stmt->execute(); 
     961        } catch (Exception $e) { 
     962            Propel::log($e->getMessage(), Propel::LOG_ERR); 
     963            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); 
     964        } 
     965 
     966        try { 
     967            $pk = $con->lastInsertId(); 
     968        } catch (Exception $e) { 
     969            throw new PropelException('Unable to get autoincrement id.', $e); 
     970        } 
     971        $this->setId($pk); 
     972 
     973        $this->setNew(false); 
     974    } 
     975 
     976    /** 
     977     * Update the row in the database. 
     978     * 
     979     * @param      PropelPDO $con 
     980     * 
     981     * @see        doSave() 
     982     */ 
     983    protected function doUpdate(PropelPDO $con) 
     984    { 
     985        $selectCriteria = $this->buildPkeyCriteria(); 
     986        $valuesCriteria = $this->buildCriteria(); 
     987        BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); 
     988    } 
    837989 
    838990    /** 
     
    13381490    /** 
    13391491     * Initializes a collection based on the name of a relation. 
    1340      * Avoids crafting an 'init[$relationName]s' method name  
     1492     * Avoids crafting an 'init[$relationName]s' method name 
    13411493     * that wouldn't work when StandardEnglishPluralizer is used. 
    13421494     * 
     
    14201572 
    14211573    /** 
     1574     * Sets a collection of UserCredential objects related by a one-to-many relationship 
     1575     * to the current object. 
     1576     * It will also schedule objects for deletion based on a diff between old objects (aka persisted) 
     1577     * and new objects from the given Propel collection. 
     1578     * 
     1579     * @param      PropelCollection $userCredentials A Propel collection. 
     1580     * @param      PropelPDO $con Optional connection object 
     1581     */ 
     1582    public function setUserCredentials(PropelCollection $userCredentials, PropelPDO $con = null) 
     1583    { 
     1584        $this->userCredentialsScheduledForDeletion = $this->getUserCredentials(new Criteria(), $con)->diff($userCredentials); 
     1585 
     1586        foreach ($userCredentials as $userCredential) { 
     1587            // Fix issue with collection modified by reference 
     1588            if ($userCredential->isNew()) { 
     1589                $userCredential->setUser($this); 
     1590            } 
     1591            $this->addUserCredential($userCredential); 
     1592        } 
     1593 
     1594        $this->collUserCredentials = $userCredentials; 
     1595    } 
     1596 
     1597    /** 
    14221598     * Returns the number of related UserCredential objects. 
    14231599     * 
     
    14521628     * 
    14531629     * @param      UserCredential $l UserCredential 
    1454      * @return     void 
    1455      * @throws     PropelException 
     1630     * @return     User The current object (for fluent API support) 
    14561631     */ 
    14571632    public function addUserCredential(UserCredential $l) 
     
    14611636        } 
    14621637        if (!$this->collUserCredentials->contains($l)) { // only add it if the **same** object is not already associated 
    1463             $this->collUserCredentials[]= $l; 
    1464             $l->setUser($this); 
    1465         } 
     1638            $this->doAddUserCredential($l); 
     1639        } 
     1640 
     1641        return $this; 
     1642    } 
     1643 
     1644    /** 
     1645     * @param   UserCredential $userCredential The userCredential object to add. 
     1646     */ 
     1647    protected function doAddUserCredential($userCredential) 
     1648    { 
     1649        $this->collUserCredentials[]= $userCredential; 
     1650        $userCredential->setUser($this); 
    14661651    } 
    14671652 
     
    15551740 
    15561741    /** 
     1742     * Sets a collection of Credential objects related by a many-to-many relationship 
     1743     * to the current object by way of the user_credential cross-reference table. 
     1744     * It will also schedule objects for deletion based on a diff between old objects (aka persisted) 
     1745     * and new objects from the given Propel collection. 
     1746     * 
     1747     * @param      PropelCollection $credentials A Propel collection. 
     1748     * @param      PropelPDO $con Optional connection object 
     1749     */ 
     1750    public function setCredentials(PropelCollection $credentials, PropelPDO $con = null) 
     1751    { 
     1752        $userCredentials = UserCredentialQuery::create() 
     1753            ->filterByCredential($credentials) 
     1754            ->filterByUser($this) 
     1755            ->find($con); 
     1756 
     1757        $this->credentialsScheduledForDeletion = $this->getUserCredentials()->diff($userCredentials); 
     1758        $this->collUserCredentials = $userCredentials; 
     1759 
     1760        foreach ($credentials as $credential) { 
     1761            // Fix issue with collection modified by reference 
     1762            if ($credential->isNew()) { 
     1763                $this->doAddCredential($credential); 
     1764            } else { 
     1765                $this->addCredential($credential); 
     1766            } 
     1767        } 
     1768 
     1769        $this->collCredentials = $credentials; 
     1770    } 
     1771 
     1772    /** 
    15571773     * Gets the number of Credential objects related by a many-to-many relationship 
    15581774     * to the current object by way of the user_credential cross-reference table. 
     
    15961812        } 
    15971813        if (!$this->collCredentials->contains($credential)) { // only add it if the **same** object is not already associated 
    1598             $userCredential = new UserCredential(); 
    1599             $userCredential->setCredential($credential); 
    1600             $this->addUserCredential($userCredential); 
     1814            $this->doAddCredential($credential); 
    16011815 
    16021816            $this->collCredentials[]= $credential; 
    16031817        } 
     1818    } 
     1819 
     1820    /** 
     1821     * @param   Credential $credential The credential object to add. 
     1822     */ 
     1823    protected function doAddCredential($credential) 
     1824    { 
     1825        $userCredential = new UserCredential(); 
     1826        $userCredential->setCredential($credential); 
     1827        $this->addUserCredential($userCredential); 
    16041828    } 
    16051829 
     
    20152239     * Gets number of children for the given node 
    20162240     * 
    2017      * @param      Criteria  $criteria Criteria to filter results.  
     2241     * @param      Criteria  $criteria Criteria to filter results. 
    20182242     * @param      PropelPDO $con Connection to use. 
    20192243     * @return     int       Number of children 
     
    20372261     * Gets the first child of the given node 
    20382262     * 
    2039      * @param      Criteria $query Criteria to filter results.  
     2263     * @param      Criteria $query Criteria to filter results. 
    20402264     * @param      PropelPDO $con Connection to use. 
    20412265     * @return     array        List of User objects 
     
    20562280     * Gets the last child of the given node 
    20572281     * 
    2058      * @param      Criteria $query Criteria to filter results.  
     2282     * @param      Criteria $query Criteria to filter results. 
    20592283     * @param      PropelPDO $con Connection to use. 
    20602284     * @return     array        List of User objects 
     
    20762300     * 
    20772301     * @param      bool         $includeNode Whether to include the current node or not 
    2078      * @param      Criteria $query Criteria to filter results.  
     2302     * @param      Criteria $query Criteria to filter results. 
    20792303     * @param      PropelPDO $con Connection to use. 
    20802304     * 
     
    20992323     * Gets descendants for the given node 
    21002324     * 
    2101      * @param      Criteria $query Criteria to filter results.  
     2325     * @param      Criteria $query Criteria to filter results. 
    21022326     * @param      PropelPDO $con Connection to use. 
    21032327     * @return     array        List of User objects 
     
    21182342     * Gets number of descendants for the given node 
    21192343     * 
    2120      * @param      Criteria $query Criteria to filter results.  
     2344     * @param      Criteria $query Criteria to filter results. 
    21212345     * @param      PropelPDO $con Connection to use. 
    21222346     * @return     int      Number of descendants 
     
    21372361     * Gets descendants for the given node, plus the current node 
    21382362     * 
    2139      * @param      Criteria $query Criteria to filter results.  
     2363     * @param      Criteria $query Criteria to filter results. 
    21402364     * @param      PropelPDO $con Connection to use. 
    21412365     * @return     array        List of User objects 
     
    21532377     * Use it for breadcrumb paths for instance 
    21542378     * 
    2155      * @param      Criteria $query Criteria to filter results.  
     2379     * @param      Criteria $query Criteria to filter results. 
    21562380     * @param      PropelPDO $con Connection to use. 
    21572381     * @return     array        List of User objects 
     
    22092433        // update the children collection of the parent 
    22102434        $parent->addNestedSetChild($this); 
    2211          
     2435     
    22122436        // Keep the tree modification query for the save() transaction 
    22132437        $this->nestedSetQueries []= array( 
     
    22392463        // update the children collection of the parent 
    22402464        $parent->addNestedSetChild($this); 
    2241          
     2465     
    22422466        // Keep the tree modification query for the save() transaction 
    22432467        $this->nestedSetQueries []= array( 
     
    23192543            throw new PropelException('Cannot move a node as child of one of its subtree nodes.'); 
    23202544        } 
    2321          
     2545     
    23222546        $this->moveSubtreeTo($parent->getLeftValue() + 1, $parent->getLevel() - $this->getLevel() + 1, $con); 
    2323          
     2547     
    23242548        return $this; 
    23252549    } 
     
    23422566            throw new PropelException('Cannot move a node as child of one of its subtree nodes.'); 
    23432567        } 
    2344          
     2568     
    23452569        $this->moveSubtreeTo($parent->getRightValue(), $parent->getLevel() - $this->getLevel() + 1, $con); 
    2346          
     2570     
    23472571        return $this; 
    23482572    } 
     
    23682592            throw new PropelException('Cannot move a node as sibling of one of its subtree nodes.'); 
    23692593        } 
    2370          
     2594     
    23712595        $this->moveSubtreeTo($sibling->getLeftValue(), $sibling->getLevel() - $this->getLevel(), $con); 
    2372          
     2596     
    23732597        return $this; 
    23742598    } 
     
    23942618            throw new PropelException('Cannot move a node as sibling of one of its subtree nodes.'); 
    23952619        } 
    2396          
     2620     
    23972621        $this->moveSubtreeTo($sibling->getRightValue() + 1, $sibling->getLevel() - $this->getLevel(), $con); 
    2398          
     2622     
    23992623        return $this; 
    24002624    } 
     
    24132637     
    24142638        $treeSize = $right - $left +1; 
    2415          
     2639     
    24162640        if ($con === null) { 
    24172641            $con = Propel::getConnection(UserPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); 
    24182642        } 
    2419              
     2643     
    24202644        $con->beginTransaction(); 
    24212645        try { 
    24222646            // make room next to the target for the subtree 
    24232647            UserPeer::shiftRLValues($treeSize, $destLeft, null, $con); 
    2424          
     2648     
    24252649            if ($left >= $destLeft) { // src was shifted too? 
    24262650                $left += $treeSize; 
    24272651                $right += $treeSize; 
    24282652            } 
    2429              
     2653     
    24302654            if ($levelDelta) { 
    24312655                // update the levels of the subtree 
    24322656                UserPeer::shiftLevel($levelDelta, $left, $right, $con); 
    24332657            } 
    2434              
     2658     
    24352659            // move the subtree to the target 
    24362660            UserPeer::shiftRLValues($destLeft - $left, $left, $right, $con); 
    2437          
     2661     
    24382662            // remove the empty room at the previous location of the subtree 
    24392663            UserPeer::shiftRLValues(-$treeSize, $right + 1, null, $con); 
    2440              
     2664     
    24412665            // update all loaded nodes 
    24422666            UserPeer::updateLoadedNodes(null, $con); 
    2443              
     2667     
    24442668            $con->commit(); 
    24452669        } catch (PropelException $e) { 
     
    24512675    /** 
    24522676     * Deletes all descendants for the given node 
    2453      * Instance pooling is wiped out by this command,  
     2677     * Instance pooling is wiped out by this command, 
    24542678     * so existing User instances are probably invalid (except for the current one) 
    24552679     * 
     
    24752699                ->descendantsOf($this) 
    24762700                ->delete($con); 
    2477              
     2701     
    24782702            // fill up the room that was used by descendants 
    24792703            UserPeer::shiftRLValues($left - $right + 1, $right, null, $con); 
    2480              
     2704     
    24812705            // fix the right value for the current node, which is now a leaf 
    24822706            $this->setRightValue($left + 1); 
    2483              
     2707     
    24842708            $con->commit(); 
    24852709        } catch (Exception $e) { 
     
    24872711            throw $e; 
    24882712        } 
    2489          
     2713     
    24902714        return $ret; 
    24912715    } 
     
    25012725    } 
    25022726 
    2503     /** 
    2504      * Catches calls to virtual methods 
    2505      */ 
    2506     public function __call($name, $params) 
    2507     { 
    2508         if (preg_match('/get(\w+)/', $name, $matches)) { 
    2509             $virtualColumn = $matches[1]; 
    2510             if ($this->hasVirtualColumn($virtualColumn)) { 
    2511                 return $this->getVirtualColumn($virtualColumn); 
    2512             } 
    2513             // no lcfirst in php<5.3... 
    2514             $virtualColumn[0] = strtolower($virtualColumn[0]); 
    2515             if ($this->hasVirtualColumn($virtualColumn)) { 
    2516                 return $this->getVirtualColumn($virtualColumn); 
    2517             } 
    2518         } 
    2519         return parent::__call($name, $params); 
    2520     } 
    2521  
    25222727} // BaseUser 
  • branches/Credentials/app/lib/propelom/om/BaseUserCredential.php

    r48 r59  
    265265        $con->beginTransaction(); 
    266266        try { 
     267            $deleteQuery = UserCredentialQuery::create() 
     268                ->filterByPrimaryKey($this->getPrimaryKey()); 
    267269            $ret = $this->preDelete($con); 
    268270            if ($ret) { 
    269                 UserCredentialQuery::create() 
    270                     ->filterByPrimaryKey($this->getPrimaryKey()) 
    271                     ->delete($con); 
     271                $deleteQuery->delete($con); 
    272272                $this->postDelete($con); 
    273273                $con->commit(); 
     
    276276                $con->commit(); 
    277277            } 
    278         } catch (PropelException $e) { 
     278        } catch (Exception $e) { 
    279279            $con->rollBack(); 
    280280            throw $e; 
     
    328328            $con->commit(); 
    329329            return $affectedRows; 
    330         } catch (PropelException $e) { 
     330        } catch (Exception $e) { 
    331331            $con->rollBack(); 
    332332            throw $e; 
     
    370370            } 
    371371 
    372  
    373             // If this object has been modified, then save it to the database. 
    374             if ($this->isModified()) { 
     372            if ($this->isNew() || $this->isModified()) { 
     373                // persist changes 
    375374                if ($this->isNew()) { 
    376                     $criteria = $this->buildCriteria(); 
    377                     $pk = BasePeer::doInsert($criteria, $con); 
    378                     $affectedRows += 1; 
    379                     $this->setNew(false); 
     375                    $this->doInsert($con); 
    380376                } else { 
    381                     $affectedRows += UserCredentialPeer::doUpdate($this, $con); 
     377                    $this->doUpdate($con); 
    382378                } 
    383  
    384                 $this->resetModified(); // [HL] After being saved an object is no longer 'modified' 
     379                $affectedRows += 1; 
     380                $this->resetModified(); 
    385381            } 
    386382 
     
    390386        return $affectedRows; 
    391387    } // doSave() 
     388 
     389    /** 
     390     * Insert the row in the database. 
     391     * 
     392     * @param      PropelPDO $con 
     393     * 
     394     * @throws     PropelException 
     395     * @see        doSave() 
     396     */ 
     397    protected function doInsert(PropelPDO $con) 
     398    { 
     399        $modifiedColumns = array(); 
     400        $index = 0; 
     401 
     402 
     403         // check the columns in natural order for more readable SQL queries 
     404        if ($this->isColumnModified(UserCredentialPeer::USER_ID)) { 
     405            $modifiedColumns[':p' . $index++]  = '`USER_ID`'; 
     406        } 
     407        if ($this->isColumnModified(UserCredentialPeer::CREDENTIAL_ID)) { 
     408            $modifiedColumns[':p' . $index++]  = '`CREDENTIAL_ID`'; 
     409        } 
     410 
     411        $sql = sprintf( 
     412            'INSERT INTO `user_credential` (%s) VALUES (%s)', 
     413            implode(', ', $modifiedColumns), 
     414            implode(', ', array_keys($modifiedColumns)) 
     415        ); 
     416 
     417        try { 
     418            $stmt = $con->prepare($sql); 
     419            foreach ($modifiedColumns as $identifier => $columnName) { 
     420                switch ($columnName) { 
     421                    case '`USER_ID`': 
     422                        $stmt->bindValue($identifier, $this->user_id, PDO::PARAM_INT); 
     423                        break; 
     424                    case '`CREDENTIAL_ID`': 
     425                        $stmt->bindValue($identifier, $this->credential_id, PDO::PARAM_INT); 
     426                        break; 
     427                } 
     428            } 
     429            $stmt->execute(); 
     430        } catch (Exception $e) { 
     431            Propel::log($e->getMessage(), Propel::LOG_ERR); 
     432            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); 
     433        } 
     434 
     435        $this->setNew(false); 
     436    } 
     437 
     438    /** 
     439     * Update the row in the database. 
     440     * 
     441     * @param      PropelPDO $con 
     442     * 
     443     * @see        doSave() 
     444     */ 
     445    protected function doUpdate(PropelPDO $con) 
     446    { 
     447        $selectCriteria = $this->buildPkeyCriteria(); 
     448        $valuesCriteria = $this->buildCriteria(); 
     449        BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); 
     450    } 
    392451 
    393452    /** 
     
    883942    } 
    884943 
    885     /** 
    886      * Catches calls to virtual methods 
    887      */ 
    888     public function __call($name, $params) 
    889     { 
    890         if (preg_match('/get(\w+)/', $name, $matches)) { 
    891             $virtualColumn = $matches[1]; 
    892             if ($this->hasVirtualColumn($virtualColumn)) { 
    893                 return $this->getVirtualColumn($virtualColumn); 
    894             } 
    895             // no lcfirst in php<5.3... 
    896             $virtualColumn[0] = strtolower($virtualColumn[0]); 
    897             if ($this->hasVirtualColumn($virtualColumn)) { 
    898                 return $this->getVirtualColumn($virtualColumn); 
    899             } 
    900         } 
    901         return parent::__call($name, $params); 
    902     } 
    903  
    904944} // BaseUserCredential 
  • branches/Credentials/app/lib/propelom/om/BaseUserCredentialPeer.php

    r48 r59  
    2525    /** the related TableMap class for this table */ 
    2626    const TM_CLASS = 'UserCredentialTableMap'; 
    27      
     27 
    2828    /** The total number of columns. */ 
    2929    const NUM_COLUMNS = 2; 
     
    4343    /** The default string format for model objects of the related table **/ 
    4444    const DEFAULT_STRING_FORMAT = 'YAML'; 
    45      
     45 
    4646    /** 
    4747     * An identiy map to hold any loaded instances of UserCredential objects. 
     
    372372 
    373373    /** 
    374      * Retrieves the primary key from the DB resultset row  
     374     * Retrieves the primary key from the DB resultset row 
    375375     * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with 
    376376     * a multi-column primary key, an array of the primary key columns will be returned. 
     
    469469            UserCredentialPeer::addSelectColumns($criteria); 
    470470        } 
    471          
     471 
    472472        $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count 
    473          
     473 
    474474        // Set the correct dbName 
    475475        $criteria->setDbName(self::DATABASE_NAME); 
     
    519519            UserCredentialPeer::addSelectColumns($criteria); 
    520520        } 
    521          
     521 
    522522        $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count 
    523          
     523 
    524524        // Set the correct dbName 
    525525        $criteria->setDbName(self::DATABASE_NAME); 
     
    701701            UserCredentialPeer::addSelectColumns($criteria); 
    702702        } 
    703          
     703 
    704704        $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count 
    705          
     705 
    706706        // Set the correct dbName 
    707707        $criteria->setDbName(self::DATABASE_NAME); 
     
    836836        // tables go into the FROM clause. 
    837837        $criteria->setPrimaryTableName(UserCredentialPeer::TABLE_NAME); 
    838          
     838 
    839839        if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { 
    840840            $criteria->setDistinct(); 
     
    844844            UserCredentialPeer::addSelectColumns($criteria); 
    845845        } 
    846          
     846 
    847847        $criteria->clearOrderByColumns(); // ORDER BY should not affect count 
    848          
     848 
    849849        // Set the correct dbName 
    850850        $criteria->setDbName(self::DATABASE_NAME); 
     
    886886        // tables go into the FROM clause. 
    887887        $criteria->setPrimaryTableName(UserCredentialPeer::TABLE_NAME); 
    888          
     888 
    889889        if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { 
    890890            $criteria->setDistinct(); 
     
    894894            UserCredentialPeer::addSelectColumns($criteria); 
    895895        } 
    896          
     896 
    897897        $criteria->clearOrderByColumns(); // ORDER BY should not affect count 
    898          
     898 
    899899        // Set the correct dbName 
    900900        $criteria->setDbName(self::DATABASE_NAME); 
  • branches/Credentials/app/lib/propelom/om/BaseUserCredentialQuery.php

    r48 r59  
    3838abstract class BaseUserCredentialQuery extends ModelCriteria 
    3939{ 
    40  
     40     
    4141    /** 
    4242     * Initializes internal state of BaseUserCredentialQuery object. 
     
    7575 
    7676    /** 
    77      * Find object by primary key 
     77     * Find object by primary key. 
     78     * Propel uses the instance pool to skip the database if the object exists. 
     79     * Go fast if the query is untouched. 
     80     * 
    7881     * <code> 
    7982     * $obj = $c->findPk(array(12, 34), $con); 
    8083     * </code> 
     84     * 
    8185     * @param     array[$user_id, $credential_id] $key Primary key to use for the query 
    8286     * @param     PropelPDO $con an optional connection object 
     
    8690    public function findPk($key, $con = null) 
    8791    { 
    88         if ((null !== ($obj = UserCredentialPeer::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && $this->getFormatter()->isObjectFormatter()) { 
     92        if ($key === null) { 
     93            return null; 
     94        } 
     95        if ((null !== ($obj = UserCredentialPeer::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { 
    8996            // the object is alredy in the instance pool 
    9097            return $obj; 
     98        } 
     99        if ($con === null) { 
     100            $con = Propel::getConnection(UserCredentialPeer::DATABASE_NAME, Propel::CONNECTION_READ); 
     101        } 
     102        $this->basePreSelect($con); 
     103        if ($this->formatter || $this->modelAlias || $this->with || $this->select 
     104         || $this->selectColumns || $this->asColumns || $this->selectModifiers 
     105         || $this->map || $this->having || $this->joins) { 
     106            return $this->findPkComplex($key, $con); 
    91107        } else { 
    92             // the object has not been requested yet, or the formatter is not an object formatter 
    93             $criteria = $this->isKeepQuery() ? clone $this : $this; 
    94             $stmt = $criteria 
    95                 ->filterByPrimaryKey($key) 
    96                 ->getSelectStatement($con); 
    97             return $criteria->getFormatter()->init($criteria)->formatOne($stmt); 
    98         } 
     108            return $this->findPkSimple($key, $con); 
     109        } 
     110    } 
     111 
     112    /** 
     113     * Find object by primary key using raw SQL to go fast. 
     114     * Bypass doSelect() and the object formatter by using generated code. 
     115     * 
     116     * @param     mixed $key Primary key to use for the query 
     117     * @param     PropelPDO $con A connection object 
     118     * 
     119     * @return    UserCredential A model object, or null if the key is not found 
     120     */ 
     121    protected function findPkSimple($key, $con) 
     122    { 
     123        $sql = 'SELECT `USER_ID`, `CREDENTIAL_ID` FROM `user_credential` WHERE `USER_ID` = :p0 AND `CREDENTIAL_ID` = :p1'; 
     124        try { 
     125            $stmt = $con->prepare($sql); 
     126            $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); 
     127            $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT); 
     128            $stmt->execute(); 
     129        } catch (Exception $e) { 
     130            Propel::log($e->getMessage(), Propel::LOG_ERR); 
     131            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); 
     132        } 
     133        $obj = null; 
     134        if ($row = $stmt->fetch(PDO::FETCH_NUM)) { 
     135            $obj = new UserCredential(); 
     136            $obj->hydrate($row); 
     137            UserCredentialPeer::addInstanceToPool($obj, serialize(array((string) $row[0], (string) $row[1]))); 
     138        } 
     139        $stmt->closeCursor(); 
     140 
     141        return $obj; 
     142    } 
     143 
     144    /** 
     145     * Find object by primary key. 
     146     * 
     147     * @param     mixed $key Primary key to use for the query 
     148     * @param     PropelPDO $con A connection object 
     149     * 
     150     * @return    UserCredential|array|mixed the result, formatted by the current formatter 
     151     */ 
     152    protected function findPkComplex($key, $con) 
     153    { 
     154        // As the query uses a PK condition, no limit(1) is necessary. 
     155        $criteria = $this->isKeepQuery() ? clone $this : $this; 
     156        $stmt = $criteria 
     157            ->filterByPrimaryKey($key) 
     158            ->doSelect($con); 
     159        return $criteria->getFormatter()->init($criteria)->formatOne($stmt); 
    99160    } 
    100161 
     
    111172    public function findPks($keys, $con = null) 
    112173    { 
     174        if ($con === null) { 
     175            $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); 
     176        } 
     177        $this->basePreSelect($con); 
    113178        $criteria = $this->isKeepQuery() ? clone $this : $this; 
    114         return $this 
     179        $stmt = $criteria 
    115180            ->filterByPrimaryKeys($keys) 
    116             ->find($con); 
     181            ->doSelect($con); 
     182        return $criteria->getFormatter()->init($criteria)->format($stmt); 
    117183    } 
    118184 
     
    128194        $this->addUsingAlias(UserCredentialPeer::USER_ID, $key[0], Criteria::EQUAL); 
    129195        $this->addUsingAlias(UserCredentialPeer::CREDENTIAL_ID, $key[1], Criteria::EQUAL); 
    130          
     196 
    131197        return $this; 
    132198    } 
     
    150216            $this->addOr($cton0); 
    151217        } 
    152          
     218 
    153219        return $this; 
    154220    } 
     
    156222    /** 
    157223     * Filter the query on the user_id column 
    158      *  
     224     * 
    159225     * Example usage: 
    160226     * <code> 
     
    184250    /** 
    185251     * Filter the query on the credential_id column 
    186      *  
     252     * 
    187253     * Example usage: 
    188254     * <code> 
     
    236302    /** 
    237303     * Adds a JOIN clause to the query using the User relation 
    238      *  
     304     * 
    239305     * @param     string $relationAlias optional alias for the relation 
    240306     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join' 
     
    246312        $tableMap = $this->getTableMap(); 
    247313        $relationMap = $tableMap->getRelation('User'); 
    248          
     314 
    249315        // create a ModelJoin object for this join 
    250316        $join = new ModelJoin(); 
     
    254320            $join->setPreviousJoin($previousJoin); 
    255321        } 
    256          
     322 
    257323        // add the ModelJoin to the current object 
    258324        if($relationAlias) { 
     
    262328            $this->addJoinObject($join, 'User'); 
    263329        } 
    264          
     330 
    265331        return $this; 
    266332    } 
     
    270336     * 
    271337     * @see       useQuery() 
    272      *  
     338     * 
    273339     * @param     string $relationAlias optional alias for the relation, 
    274340     *                                   to be used as main alias in the secondary query 
     
    310376    /** 
    311377     * Adds a JOIN clause to the query using the Credential relation 
    312      *  
     378     * 
    313379     * @param     string $relationAlias optional alias for the relation 
    314380     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join' 
     
    320386        $tableMap = $this->getTableMap(); 
    321387        $relationMap = $tableMap->getRelation('Credential'); 
    322          
     388 
    323389        // create a ModelJoin object for this join 
    324390        $join = new ModelJoin(); 
     
    328394            $join->setPreviousJoin($previousJoin); 
    329395        } 
    330          
     396 
    331397        // add the ModelJoin to the current object 
    332398        if($relationAlias) { 
     
    336402            $this->addJoinObject($join, 'Credential'); 
    337403        } 
    338          
     404 
    339405        return $this; 
    340406    } 
     
    344410     * 
    345411     * @see       useQuery() 
    346      *  
     412     * 
    347413     * @param     string $relationAlias optional alias for the relation, 
    348414     *                                   to be used as main alias in the secondary query 
     
    371437            $this->addCond('pruneCond1', $this->getAliasedColName(UserCredentialPeer::CREDENTIAL_ID), $userCredential->getCredentialId(), Criteria::NOT_EQUAL); 
    372438            $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); 
    373       } 
    374        
     439        } 
     440 
    375441        return $this; 
    376442    } 
  • branches/Credentials/app/lib/propelom/om/BaseUserPeer.php

    r48 r59  
    2525    /** the related TableMap class for this table */ 
    2626    const TM_CLASS = 'UserTableMap'; 
    27      
     27 
    2828    /** The total number of columns. */ 
    2929    const NUM_COLUMNS = 11; 
     
    7070    /** The default string format for model objects of the related table **/ 
    7171    const DEFAULT_STRING_FORMAT = 'YAML'; 
    72      
     72 
    7373    /** 
    7474     * An identiy map to hold any loaded instances of User objects. 
     
    434434 
    435435    /** 
    436      * Retrieves the primary key from the DB resultset row  
     436     * Retrieves the primary key from the DB resultset row 
    437437     * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with 
    438438     * a multi-column primary key, an array of the primary key columns will be returned. 
     
    531531            UserPeer::addSelectColumns($criteria); 
    532532        } 
    533          
     533 
    534534        $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count 
    535          
     535 
    536536        // Set the correct dbName 
    537537        $criteria->setDbName(self::DATABASE_NAME); 
     
    647647            UserPeer::addSelectColumns($criteria); 
    648648        } 
    649          
     649 
    650650        $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count 
    651          
     651 
    652652        // Set the correct dbName 
    653653        $criteria->setDbName(self::DATABASE_NAME); 
     
    10651065        } 
    10661066        $criteria->addAscendingOrderByColumn(UserPeer::LEFT_COL); 
    1067          
     1067     
    10681068        return UserPeer::doSelect($criteria, $con); 
    10691069    } 
     
    11181118        } 
    11191119        $whereCriteria->add($criterion); 
    1120          
     1120     
    11211121        $valuesCriteria = new Criteria(UserPeer::DATABASE_NAME); 
    11221122        $valuesCriteria->add(UserPeer::LEFT_COL, array('raw' => UserPeer::LEFT_COL . ' + ?', 'value' => $delta), Criteria::CUSTOM_EQUAL); 
     
    11561156        $whereCriteria->add(UserPeer::LEFT_COL, $first, Criteria::GREATER_EQUAL); 
    11571157        $whereCriteria->add(UserPeer::RIGHT_COL, $last, Criteria::LESS_EQUAL); 
    1158          
     1158     
    11591159        $valuesCriteria = new Criteria(UserPeer::DATABASE_NAME); 
    11601160        $valuesCriteria->add(UserPeer::LEVEL_COL, array('raw' => UserPeer::LEVEL_COL . ' + ?', 'value' => $delta), Criteria::CUSTOM_EQUAL); 
     
    12391239                UserPeer::addInstanceToPool($obj, $key); 
    12401240            } 
    1241              
     1241     
    12421242            // compute level 
    12431243            // Algorithm shamelessly stolen from sfPropelActAsNestedSetBehaviorPlugin 
     
    12541254                $prev[$i] = $obj->getRightValue(); 
    12551255            } 
    1256              
     1256     
    12571257            // update level in node if necessary 
    12581258            if ($obj->getLevel() !== $level) { 
  • branches/Credentials/app/lib/propelom/om/BaseUserQuery.php

    r48 r59  
    7474abstract class BaseUserQuery extends ModelCriteria 
    7575{ 
    76  
     76     
    7777    /** 
    7878     * Initializes internal state of BaseUserQuery object. 
     
    111111 
    112112    /** 
    113      * Find object by primary key 
    114      * Use instance pooling to avoid a database query if the object exists 
     113     * Find object by primary key. 
     114     * Propel uses the instance pool to skip the database if the object exists. 
     115     * Go fast if the query is untouched. 
     116     * 
    115117     * <code> 
    116118     * $obj  = $c->findPk(12, $con); 
    117119     * </code> 
     120     * 
    118121     * @param     mixed $key Primary key to use for the query 
    119122     * @param     PropelPDO $con an optional connection object 
     
    123126    public function findPk($key, $con = null) 
    124127    { 
    125         if ((null !== ($obj = UserPeer::getInstanceFromPool((string) $key))) && $this->getFormatter()->isObjectFormatter()) { 
     128        if ($key === null) { 
     129            return null; 
     130        } 
     131        if ((null !== ($obj = UserPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { 
    126132            // the object is alredy in the instance pool 
    127133            return $obj; 
     134        } 
     135        if ($con === null) { 
     136            $con = Propel::getConnection(UserPeer::DATABASE_NAME, Propel::CONNECTION_READ); 
     137        } 
     138        $this->basePreSelect($con); 
     139        if ($this->formatter || $this->modelAlias || $this->with || $this->select 
     140         || $this->selectColumns || $this->asColumns || $this->selectModifiers 
     141         || $this->map || $this->having || $this->joins) { 
     142            return $this->findPkComplex($key, $con); 
    128143        } else { 
    129             // the object has not been requested yet, or the formatter is not an object formatter 
    130             $criteria = $this->isKeepQuery() ? clone $this : $this; 
    131             $stmt = $criteria 
    132                 ->filterByPrimaryKey($key) 
    133                 ->getSelectStatement($con); 
    134             return $criteria->getFormatter()->init($criteria)->formatOne($stmt); 
    135         } 
     144            return $this->findPkSimple($key, $con); 
     145        } 
     146    } 
     147 
     148    /** 
     149     * Find object by primary key using raw SQL to go fast. 
     150     * Bypass doSelect() and the object formatter by using generated code. 
     151     * 
     152     * @param     mixed $key Primary key to use for the query 
     153     * @param     PropelPDO $con A connection object 
     154     * 
     155     * @return    User A model object, or null if the key is not found 
     156     */ 
     157    protected function findPkSimple($key, $con) 
     158    { 
     159        $sql = 'SELECT `ID`, `USERNAME`, `EMAIL`, `SALT`, `PASSWORD`, `ROLE_ID`, `LOGIN_FAILURE_COUNT`, `LOGIN_FAILURE_DATE`, `TREE_LEFT`, `TREE_RIGHT`, `TREE_LEVEL` FROM `user` WHERE `ID` = :p0'; 
     160        try { 
     161            $stmt = $con->prepare($sql); 
     162            $stmt->bindValue(':p0', $key, PDO::PARAM_INT); 
     163            $stmt->execute(); 
     164        } catch (Exception $e) { 
     165            Propel::log($e->getMessage(), Propel::LOG_ERR); 
     166            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); 
     167        } 
     168        $obj = null; 
     169        if ($row = $stmt->fetch(PDO::FETCH_NUM)) { 
     170            $obj = new User(); 
     171            $obj->hydrate($row); 
     172            UserPeer::addInstanceToPool($obj, (string) $row[0]); 
     173        } 
     174        $stmt->closeCursor(); 
     175 
     176        return $obj; 
     177    } 
     178 
     179    /** 
     180     * Find object by primary key. 
     181     * 
     182     * @param     mixed $key Primary key to use for the query 
     183     * @param     PropelPDO $con A connection object 
     184     * 
     185     * @return    User|array|mixed the result, formatted by the current formatter 
     186     */ 
     187    protected function findPkComplex($key, $con) 
     188    { 
     189        // As the query uses a PK condition, no limit(1) is necessary. 
     190        $criteria = $this->isKeepQuery() ? clone $this : $this; 
     191        $stmt = $criteria 
     192            ->filterByPrimaryKey($key) 
     193            ->doSelect($con); 
     194        return $criteria->getFormatter()->init($criteria)->formatOne($stmt); 
    136195    } 
    137196 
     
    148207    public function findPks($keys, $con = null) 
    149208    { 
     209        if ($con === null) { 
     210            $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); 
     211        } 
     212        $this->basePreSelect($con); 
    150213        $criteria = $this->isKeepQuery() ? clone $this : $this; 
    151         return $this 
     214        $stmt = $criteria 
    152215            ->filterByPrimaryKeys($keys) 
    153             ->find($con); 
     216            ->doSelect($con); 
     217        return $criteria->getFormatter()->init($criteria)->format($stmt); 
    154218    } 
    155219 
     
    180244    /** 
    181245     * Filter the query on the id column 
    182      *  
     246     * 
    183247     * Example usage: 
    184248     * <code> 
     
    206270    /** 
    207271     * Filter the query on the username column 
    208      *  
     272     * 
    209273     * Example usage: 
    210274     * <code> 
     
    234298    /** 
    235299     * Filter the query on the email column 
    236      *  
     300     * 
    237301     * Example usage: 
    238302     * <code> 
     
    262326    /** 
    263327     * Filter the query on the salt column 
    264      *  
     328     * 
    265329     * Example usage: 
    266330     * <code> 
     
    290354    /** 
    291355     * Filter the query on the password column 
    292      *  
     356     * 
    293357     * Example usage: 
    294358     * <code> 
     
    318382    /** 
    319383     * Filter the query on the role_id column 
    320      *  
     384     * 
    321385     * Example usage: 
    322386     * <code> 
     
    360424    /** 
    361425     * Filter the query on the login_failure_count column 
    362      *  
     426     * 
    363427     * Example usage: 
    364428     * <code> 
     
    400464    /** 
    401465     * Filter the query on the login_failure_date column 
    402      *  
     466     * 
    403467     * Example usage: 
    404468     * <code> 
     
    442506    /** 
    443507     * Filter the query on the tree_left column 
    444      *  
     508     * 
    445509     * Example usage: 
    446510     * <code> 
     
    482546    /** 
    483547     * Filter the query on the tree_right column 
    484      *  
     548     * 
    485549     * Example usage: 
    486550     * <code> 
     
    522586    /** 
    523587     * Filter the query on the tree_level column 
    524      *  
     588     * 
    525589     * Example usage: 
    526590     * <code> 
     
    586650    /** 
    587651     * Adds a JOIN clause to the query using the Role relation 
    588      *  
     652     * 
    589653     * @param     string $relationAlias optional alias for the relation 
    590654     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join' 
     
    596660        $tableMap = $this->getTableMap(); 
    597661        $relationMap = $tableMap->getRelation('Role'); 
    598          
     662 
    599663        // create a ModelJoin object for this join 
    600664        $join = new ModelJoin(); 
     
    604668            $join->setPreviousJoin($previousJoin); 
    605669        } 
    606          
     670 
    607671        // add the ModelJoin to the current object 
    608672        if($relationAlias) { 
     
    612676            $this->addJoinObject($join, 'Role'); 
    613677        } 
    614          
     678 
    615679        return $this; 
    616680    } 
     
    620684     * 
    621685     * @see       useQuery() 
    622      *  
     686     * 
    623687     * @param     string $relationAlias optional alias for the relation, 
    624688     *                                   to be used as main alias in the secondary query 
     
    650714            return $this 
    651715                ->useUserCredentialQuery() 
    652                     ->filterByPrimaryKeys($userCredential->getPrimaryKeys()) 
     716                ->filterByPrimaryKeys($userCredential->getPrimaryKeys()) 
    653717                ->endUse(); 
    654718        } else { 
     
    659723    /** 
    660724     * Adds a JOIN clause to the query using the UserCredential relation 
    661      *  
     725     * 
    662726     * @param     string $relationAlias optional alias for the relation 
    663727     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join' 
     
    669733        $tableMap = $this->getTableMap(); 
    670734        $relationMap = $tableMap->getRelation('UserCredential'); 
    671          
     735 
    672736        // create a ModelJoin object for this join 
    673737        $join = new ModelJoin(); 
     
    677741            $join->setPreviousJoin($previousJoin); 
    678742        } 
    679          
     743 
    680744        // add the ModelJoin to the current object 
    681745        if($relationAlias) { 
     
    685749            $this->addJoinObject($join, 'UserCredential'); 
    686750        } 
    687          
     751 
    688752        return $this; 
    689753    } 
     
    693757     * 
    694758     * @see       useQuery() 
    695      *  
     759     * 
    696760     * @param     string $relationAlias optional alias for the relation, 
    697761     *                                   to be used as main alias in the secondary query 
     
    720784        return $this 
    721785            ->useUserCredentialQuery() 
    722                 ->filterByCredential($credential, $comparison) 
     786            ->filterByCredential($credential, $comparison) 
    723787            ->endUse(); 
    724788    } 
    725      
     789 
    726790    /** 
    727791     * Exclude object from result 
     
    735799        if ($user) { 
    736800            $this->addUsingAlias(UserPeer::ID, $user->getId(), Criteria::NOT_EQUAL); 
    737       } 
    738        
     801        } 
     802 
    739803        return $this; 
    740804    } 
Note: See TracChangeset for help on using the changeset viewer.