public function getCount($where) { $db = $this->_tdb->getAdapter(); $select = $db->select(); if (in_array('isdelete', $this->_tdb->_cols) && !isset($where['isdelete'])) { $where['isdelete'] = 0; } $select->from($this->_tdb->name, 'count(*) as count'); Common_Db_Util::buildSelectWhere($select, $where); $select->order($order); $select->limit($limit, $offset); try { $rs = $db->fetchRow($select); } catch (Exception $e) { throw $e; } return (int) $rs['count']; }
/** * get result in paging * @param array $select sql condition * @param number $resultnum result num in need * @param number $pagenum start number * @return boolean|Ambigous <boolean, multitype:multitype:array, multitype:multitype: > */ public function getPaging($select, $resultnum, $pagenum = 0) { if (!$select || count($select) <= 0) { return false; } $sql = 'SELECT * FROM ' . $this->tablename . ' WHERE ' . Common_Db_Util::splice('AND', $select) . ' LIMIT ' . intval($pagenum) . ',' . intval($resultnum); return Common_Db_Base::fetchAll($sql); }
public function getCount($where) { $db = $this->getAdapter(); $select = $db->select(); $cols = $this->_getCols(); if (in_array('deleted', $cols) && !isset($where['deleted'])) { $where['deleted'] = 0; } $select->from($this->_name, 'count(*) as count'); Common_Db_Util::buildSelectWhere($select, $where); try { $rs = $db->fetchRow($select); } catch (Exception $e) { throw $e; } return (int) $rs['count']; }