Zend Framework

Zend_Db_Table::fetchCount($where = null) - fetching number of row results

Details

  • Type: New Feature New Feature
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Not an Issue
  • Affects Version/s: 0.7.0
  • Fix Version/s: 1.8.0
  • Component/s: Zend_Db_Table
  • Labels:
    None
  • Fix Version Priority:
    Nice to Have

Description

i've wanted to count row results to build a nice helper which organizes my index-views more comfortable.

so i've added ..

Zend/Db/Table.php
/**
     * Fetches the number of row results.
     * 
     * @return int The number of row results
     */
    public function fetchCount($where = null)
    {
        return (int)$this->_fetch('Count', $where);
    }

.. and changed ..

Zend/Db/Table.php - protected function _fetch
// the FROM clause
       	$select->from($this->_name, array_keys($this->_cols));

.. to ..

Zend/Db/Table.php - protected function _fetch
// the FROM clause
        if ($type == 'Count') {
        	$select->from($this->_name, 'count(*)');
        	$type = 'One';
        }
        else
        	$select->from($this->_name, array_keys($this->_cols));

.. which gives me a Zend_Db_Table::fetchCount($where)-function returning the number of row results

Issue Links

Activity

Hide
Wil Sinclair added a comment -

Please categorize/fix as needed.

Show
Wil Sinclair added a comment - Please categorize/fix as needed.
Hide
Wil Sinclair added a comment -

This doesn't appear to have been fixed in 1.5.0. Please update if this is not correct.

Show
Wil Sinclair added a comment - This doesn't appear to have been fixed in 1.5.0. Please update if this is not correct.
Hide
Wil Sinclair added a comment -

Reassigning to Ralph since he's the new maintainer of Zend_Db

Show
Wil Sinclair added a comment - Reassigning to Ralph since he's the new maintainer of Zend_Db
Hide
Ralph Schindler added a comment -

A solution exists for this in this issue:

http://framework.zend.com/issues/browse/ZF-1335

Show
Ralph Schindler added a comment - A solution exists for this in this issue: http://framework.zend.com/issues/browse/ZF-1335

People

Vote (8)
Watch (5)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
2d
Original Estimate - 2 days
Remaining:
2d
Remaining Estimate - 2 days
Logged:
Not Specified
Time Spent - Not Specified