/** * Get count of record * * @param string $sql * @return int */ function _getCount($sql) { if ($result =& $this->_query($sql)) { list($count) = $this->_db->fetchRow($result); return $count; } else { return 0; } }
/** * count objects matching a criteria * * @param object $criteria {@link CriteriaElement} to match * * @return int count of objects * @access public */ public function getCount($criteria = null) { $sql = 'SELECT COUNT(*) FROM ' . $this->_db->prefix($this->_dbtable); if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { $sql .= ' ' . $criteria->renderWhere(); } if (!($result = $this->_db->query($sql))) { return 0; } list($count) = $this->_db->fetchRow($result); return $count; }
/** * @param XoopsDatabase $db * @param $table * @param $field * @param string $condition * * @return bool */ function getDbValue(XoopsDatabase $db, $table, $field, $condition = '') { $table = $db->prefix($table); $sql = "SELECT `{$field}` FROM `{$table}`"; if ($condition) { $sql .= " WHERE {$condition}"; } $result = $db->query($sql); if ($result) { $row = $db->fetchRow($result); if ($row) { return $row[0]; } } return false; }