Ejemplo n.º 1
0
 /**
  * Count (overload)
  *
  * Returns the total count of the objects records.
  * If on a related object, returns the total count of related objects records.
  *
  * @access	public
  * @param	int or array
  * @return	bool
  */
 function count()
 {
     if (empty($this->parent)) {
         $this->_prepare_for_query();
     }
     return parent::count();
 }
Ejemplo n.º 2
0
 function testShouldCountByCategoryAndAttribute()
 {
     $product_mapper = new DataMapper($this->db);
     // should find
     $product_mapper->save(new Product(array('sku' => 'foo1', 'categories' => [1], 'attributes' => ['color' => 'red'])));
     // should not find
     $product_mapper->save(new Product(array('sku' => 'foo2', 'categories' => [2], 'attributes' => ['color' => 'red'])));
     // should not find
     $product_mapper->save(new Product(array('sku' => 'foo3', 'categories' => [1], 'attributes' => ['color' => 'blue'])));
     $count = $product_mapper->count(array('category' => 1, 'attributes' => ['color' => 'red']));
     $this->assertEquals(1, $count, 'should count by attribute & category');
 }