db::count PHP Method

count() static public method

Counts a number of rows in a table
static public count ( string $table, mixed $where = '' ) : integer
$table string The table name
$where mixed Either a key/value array as AND connected where clause or a simple MySQL where clause string
return integer
    static function count($table, $where = '')
    {
        $result = self::row($table, 'count(*)', $where);
        return $result ? a::get($result, 'count(*)') : 0;
    }

Usage Example

示例#1
0
        $text .= "<br />";
    } else {
        $text .= $cap . "<br />";
        $text .= $mains . "<br />";
    }
}
//categories ------------------------
if (isset($linkspage_pref['link_menu_category']) && $linkspage_pref['link_menu_category']) {
    $mains = "";
    $cap = isset($linkspage_pref['link_menu_category_caption']) && $linkspage_pref['link_menu_category_caption'] ? $linkspage_pref['link_menu_category_caption'] : LCLAN_OPT_83;
    $sqlc = new db();
    $sql2 = new db();
    if ($sqlc->db_Select("links_page_cat", "link_category_id, link_category_name, link_category_sef", "link_category_class REGEXP '" . e_CLASS_REGEXP . "' ORDER BY link_category_order")) {
        while ($rowc = $sqlc->fetch()) {
            if (isset($linkspage_pref['link_menu_category_amount']) && $linkspage_pref['link_menu_category_amount']) {
                $amount = $sql2->count("links_page", "(*)", "WHERE link_category = '" . $rowc['link_category_id'] . "' AND link_active = 1 AND link_class REGEXP '" . e_CLASS_REGEXP . "' ");
                $amount = "(" . $amount . ")";
            } else {
                $amount = "";
            }
            if (isset($linkspage_pref['link_menu_category_rendertype']) && $linkspage_pref['link_menu_category_rendertype'] == "1") {
                $mains .= $rs->form_option($rowc['link_category_name'] . " " . $amount, "0", e107::url('links_page', 'category', $rowc, 'full'), "");
            } else {
                $mains .= $bullet . " <a href='" . e107::url('links_page', 'category', $rowc, 'full') . "'>" . $rowc['link_category_name'] . "</a> " . $amount . "<br />";
            }
        }
        if (isset($linkspage_pref['link_menu_category_rendertype']) && $linkspage_pref['link_menu_category_rendertype'] == "1") {
            $selectjs = "style='width:100%;' onchange=\"if(this.options[this.selectedIndex].value != ''){ return document.location=this.options[this.selectedIndex].value; }\" ";
            $text .= $rs->form_select_open("category", $selectjs);
            $text .= $rs->form_option($cap, "0", "", "");
            $text .= $mains;
All Usage Examples Of db::count