Changeset 4786

Show
Ignore:
Timestamp:
08/22/08 02:57:41 (11 months ago)
Author:
guilhermeblanco
Message:

fixes #1288. Added a fixed alias to findXXX methods. THe alias name is 'dctrn_find'.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/1.0/lib/Doctrine/Table.php

    r4772 r4786  
    12531253 
    12541254        $id = is_array($id) ? array_values($id) : array($id); 
    1255          
    1256         $q = $this->createQuery(); 
    1257         $q->where(implode(' = ? AND ', (array) $this->getIdentifier()) . ' = ?', $id) 
    1258                 ->limit(1); 
     1255 
     1256        $q = $this->createQuery('dctrn_find') 
     1257            ->where( 
     1258                'dctrn_find.' . implode( 
     1259                    ' = ? AND dctrn_find.', (array) $this->getIdentifier() 
     1260                ) . ' = ?', $id 
     1261            ) 
     1262            ->limit(1); 
    12591263        $res = $q->fetchOne(array(), $hydrationMode); 
    12601264        $q->free(); 
     
    12721276    public function findAll($hydrationMode = null) 
    12731277    { 
    1274         return $this->createQuery()->execute(array(), $hydrationMode); 
     1278        return $this->createQuery('dctrn_find') 
     1279            ->execute(array(), $hydrationMode); 
    12751280    } 
    12761281 
     
    12901295    public function findBySql($dql, $params = array(), $hydrationMode = null) 
    12911296    { 
    1292         return $this->createQuery()->where($dql)->execute($params, $hydrationMode); 
     1297        return $this->createQuery('dctrn_find') 
     1298            ->where($dql)->execute($params, $hydrationMode); 
    12931299    } 
    12941300 
     
    13071313        $parser = new Doctrine_Query($this->_conn); 
    13081314        $component = $this->getComponentName(); 
    1309         $query = 'FROM ' . $component . ' WHERE ' . $dql; 
     1315        $query = 'FROM ' . $component . ' dctrn_find WHERE ' . $dql; 
    13101316 
    13111317        return $parser->query($query, $params, $hydrationMode); 
     1318    } 
     1319     
     1320    /** 
     1321     * findBy 
     1322     * 
     1323     * @param string $column 
     1324     * @param string $value 
     1325     * @param string $hydrationMode 
     1326     * @return void 
     1327     */ 
     1328    protected function findBy($fieldName, $value, $hydrationMode = null) 
     1329    { 
     1330        return $this->createQuery('dctrn_find') 
     1331            ->where('dctrn_find.' . $fieldName . ' = ?', array($value)) 
     1332            ->execute(array(), $hydrationMode); 
     1333    } 
     1334 
     1335    /** 
     1336     * findOneBy 
     1337     * 
     1338     * @param string $column 
     1339     * @param string $value 
     1340     * @param string $hydrationMode 
     1341     * @return void 
     1342     */ 
     1343    protected function findOneBy($fieldName, $value, $hydrationMode = null) 
     1344    { 
     1345        $results = $this->createQuery('dctrn_find') 
     1346                        ->where('dctrn_find.' . $fieldName . ' = ?',array($value)) 
     1347                        ->limit(1) 
     1348                        ->execute(array(), $hydrationMode); 
     1349 
     1350        if (is_array($results) && isset($results[0])) { 
     1351            return $results[0]; 
     1352        } else if ($results instanceof Doctrine_Collection && $results->count() > 0) { 
     1353            return $results->getFirst(); 
     1354        } else { 
     1355            return false; 
     1356        } 
    13121357    } 
    13131358 
     
    21652210 
    21662211    /** 
    2167      * findBy 
    2168      * 
    2169      * @param string $column 
    2170      * @param string $value 
    2171      * @param string $hydrationMode 
    2172      * @return void 
    2173      */ 
    2174     protected function findBy($fieldName, $value, $hydrationMode = null) 
    2175     { 
    2176         return $this->createQuery()->where($fieldName . ' = ?', array($value))->execute(array(), $hydrationMode); 
    2177     } 
    2178  
    2179     /** 
    2180      * findOneBy 
    2181      * 
    2182      * @param string $column 
    2183      * @param string $value 
    2184      * @param string $hydrationMode 
    2185      * @return void 
    2186      */ 
    2187     protected function findOneBy($fieldName, $value, $hydrationMode = null) 
    2188     { 
    2189         $results = $this->createQuery() 
    2190                         ->where($fieldName . ' = ?',array($value)) 
    2191                         ->limit(1) 
    2192                         ->execute(array(), $hydrationMode); 
    2193  
    2194         if (is_array($results) && isset($results[0])) { 
    2195             return $results[0]; 
    2196         } else if ($results instanceof Doctrine_Collection && $results->count() > 0) { 
    2197             return $results->getFirst(); 
    2198         } else { 
    2199             return false; 
    2200         } 
    2201     } 
    2202  
    2203     /** 
    22042212     * Resolve the passed find by field name to the appropriate field name 
    22052213     * regardless of whether the user passes a column name, field name, or a Doctrine_Inflector::classified()