Changeset 8107
- Timestamp:
- 03/27/08 08:57:29 (7 months ago)
- Files:
-
- plugins/sfPropelFinderPlugin/README (modified) (2 diffs)
- plugins/sfPropelFinderPlugin/lib/sfPropelFinder.php (modified) (1 diff)
- plugins/sfPropelFinderPlugin/test/unit/sfPropelFinderTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfPropelFinderPlugin/README
r8102 r8107 89 89 }}} 90 90 91 === Counting objects === 92 93 {{{ 94 #!php 95 <?php 96 // Counting all Articles 97 $nbArticles = sfPropelFinder::from('Article')->count(); 98 }}} 99 91 100 === Combining methods === 92 101 … … 141 150 == Changelog == 142 151 152 === 2008-03-27 | Trunk === 153 154 * francois: Added `sfPropelFinder::count()` method 155 143 156 === 2008-03-27 | 0.1.0 alpha === 144 157 plugins/sfPropelFinderPlugin/lib/sfPropelFinder.php
r8101 r8107 76 76 } 77 77 78 public function find($limit = null, $con = null, $reinitCriteria = true) 78 public function count($con = null, $reinitCriteria = true) 79 { 80 $ret = call_user_func(array($this->getPeerClass(), 'doCount'), $this->criteria, $con); 81 if($reinitCriteria) 82 { 83 $this->reinitCriteria(); 84 } 85 86 return $ret; 87 88 } 89 90 public function find($limit = null, $con = null, $reinitCriteria = false) 79 91 { 80 92 if($limit) plugins/sfPropelFinderPlugin/test/unit/sfPropelFinderTest.php
r8101 r8107 88 88 89 89 $t->diag('findPk()'); 90 90 91 $finder = new sfPropelFinder('Article'); 91 92 $article = $finder->findPk($article2->getId()); … … 100 101 $t->is(count($articles), 2, 'findPk() returns the objects with the primary keys matching the arguments'); 101 102 103 $t->diag('count()'); 104 105 ArticlePeer::doDeleteAll(); 106 $finder = new sfPropelFinder('Article'); 107 $nbArticles = $finder->count(); 108 $t->is_a_ok($nbArticles, 'integer', 'count() returns an integer'); 109 $t->is($nbArticles, 0, 'count() returns 0 on empry tables'); 110 102 111 $t->diag('Instanciation possibilities'); 103 112 113 ArticlePeer::doDeleteAll(); 114 $article = new Article(); 115 $article->setTitle('foo'); 116 $article->save(); 104 117 $finder = new sfPropelFinder('Article'); 105 118 $t->is($finder->getPeerClass(), 'ArticlePeer', 'PeerClass can be set during instanciation, in which case the finder is automatically initialized');