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
Exemplo n.º 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;
Exemplo n.º 2
0
    } else {
        if (strlen($_POST['code']) != 9 or is_numeric($_POST['code']) === false) {
            $errors[] = $lang[$p]['error_invalid_code'];
        }
    }
    if (count($errors) > 0) {
        foreach ($errors as $error) {
            echo baltsms::alert($error, "danger");
        }
    } else {
        $baltsms = new baltsms();
        $baltsms->setPrice($_POST['price']);
        $baltsms->setCode($_POST['code']);
        $baltsms->sendRequest();
        if ($baltsms->getResponse() === true) {
            if ($db->count("SELECT `id` FROM `" . $c[$p]['db']['table'] . "` WHERE `name` = ?", array($_POST['name'])) == 0) {
                $db->insert("INSERT INTO `" . $c[$p]['db']['table'] . "` (`name`, `message`, `amount`, `time`) VALUES (?, ?, ?, ?)", array($_POST['name'], $_POST['message'], $_POST['price'], time()));
            } else {
                $db->update("UPDATE `" . $c[$p]['db']['table'] . "` SET `message` = ?, `amount` = `amount` + ?, `time` = ? WHERE `name` = ?", array($_POST['message'], $_POST['price'], time(), $_POST['name']));
            }
            echo baltsms::alert($lang[$p]['thanks_for_donating'], "success");
            ?>
			<script type="text/javascript">
				setTimeout(function(){
					loadPlugin('<?php 
            echo $p;
            ?>
');
				}, 3000 );
			</script>
			<?php 
Exemplo n.º 3
0
</fieldset>
</form>
<?php 
        } else {
            ?>
<fieldset><legend>忘記密碼</legend>
<label>查無此帳號!!</label></fieldset>
<?php 
        }
        break;
    case 2:
        $A = new db();
        $account = get("account");
        $answer = get("answer");
        $A->query("select * from accounts where account = '{$account}' and answer='{$answer}'");
        if ($A->count() > 0) {
            $A->fetch();
            setsession("account", get("account"));
            setsession("id", $A->element("id"));
            ?>
<form action="/44/member/" method="post">
<fieldset><legend>忘記密碼</legend>
<label>已成功回答問題,已將您登入。</label><br>
<input type="submit" value="確定">
</fieldset>
</form>
<?php 
        } else {
            ?>
<fieldset><legend>忘記密碼</legend>
<label>答案錯誤!!</label></fieldset>
Exemplo n.º 4
0
<tr><th width=130>時段</th><th width=130>是否可預約</th></tr>
<?php 
    for ($j = 0; $j < 4; $j++) {
        ?>
<tr><td><?php 
        echo section($j);
        ?>
</td>
<?php 
        $date = get("date");
        $room = get("room");
        $floor = get("floor");
        $C->query("select * from reserves where date='{$date}' and room='{$room}' and floor = '{$floor}' and section = '{$j}'");
        ?>
<td><?php 
        if ($C->count() > 0) {
            ?>
已被預約<?php 
        } else {
            ?>
 <a href="search.php?date=<?php 
            echo get("date");
            ?>
&section=<?php 
            echo $j;
            ?>
&floor=<?php 
            echo get("floor");
            ?>
&room=<?php 
            echo get("room");
Exemplo n.º 5
0
 } else {
     if (strlen($_POST['code']) != 9 or is_numeric($_POST['code']) === false) {
         $errors[] = $lang[$p]['error_invalid_code'];
     }
 }
 if (count($errors) > 0) {
     foreach ($errors as $error) {
         echo baltsms::alert($error, "danger");
     }
 } else {
     $baltsms = new baltsms();
     $baltsms->setPrice($_POST['price']);
     $baltsms->setCode($_POST['code']);
     $baltsms->sendRequest();
     if ($baltsms->getResponse() === true) {
         if ($db->count("SELECT `id` FROM `" . $c[$p]['db']['table'] . "` WHERE `nickname` = ? AND `server` = ?", array($_POST['nickname'], $_POST['server'])) == 0) {
             $db->insert("INSERT INTO `" . $c[$p]['db']['table'] . "` (`nickname`, `server`, `length`, `time`, `expires`) VALUES (?, ?, ?, ?, ?)", array($_POST['nickname'], $_POST['server'], $c[$p]['prices'][$_POST['server']][$_POST['price']], time(), strtotime("+" . $c[$p]['prices'][$_POST['server']][$_POST['price']] . " days", time())));
         } else {
             $player = $db->fetch("SELECT `expires` FROM `" . $c[$p]['db']['table'] . "` WHERE `nickname` = ? AND `server` = ?", array($_POST['nickname'], $_POST['server']));
             $db->update("UPDATE `" . $c[$p]['db']['table'] . "` SET `expires` = ? WHERE `nickname` = ? AND `server` = ?", array(strtotime("+" . $c[$p]['prices'][$_POST['server']][$_POST['price']] . " days", $player['expires']), $_POST['nickname'], $_POST['server']));
         }
         foreach ($c[$p]['commands']['giveFPeaceful'] as $command) {
             $giveFPeaceful = str_replace(array("<NICKNAME>"), array($_POST['nickname']), $command);
             $mc['rcon'][$_POST['server']]->send_command($giveFPeaceful);
         }
         if ($c[$p]['ingame']['notifications'] === true) {
             $sendMessage = str_replace(array("<NICKNAME>"), array($_POST['nickname']), $c[$p]['ingame']['message']);
             $mc['rcon'][$_POST['server']]->send_command("say " . $sendMessage);
         }
         echo baltsms::alert($lang[$p]['fpeaceful_purchased'], "success");
         ?>
Exemplo n.º 6
0
 public function testCount()
 {
     $this->assertEquals(3, db::count('users'));
 }
Exemplo n.º 7
0
 function checklayout($str)
 {
     // Displays a basic representation of the theme
     global $PLUGINS_DIRECTORY, $rs, $sc_style, $menu_order, $style;
     // global $style required.
     $PLUGINS_DIRECTORY = e107::getFolder('PLUGINS');
     $pref = e107::getPref();
     $tp = e107::getParser();
     $ns = e107::getRender();
     $menuLayout = $this->curLayout != $pref['sitetheme_deflayout'] ? $this->curLayout : "";
     //	if(strstr($str, "LOGO"))
     //	{
     //		echo $tp->parseTemplate("{LOGO}");
     //	}
     if (strstr($str, "SETSTYLE")) {
         $tmp = explode("=", $str);
         $style = preg_replace("/\\{SETSTYLE=(.*?)\\}/si", "\\1", $str);
         $this->style = $style;
         $ns->setStyle($style);
     } elseif (strstr($str, "NAVIGATION")) {
         echo "<span class='label label-info'>Navigation Area</span>";
     } elseif (strstr($str, "ALERT")) {
         //echo "[Navigation Area]";
     } elseif (strstr($str, "LANGUAGELINKS")) {
         echo "<div class=text style='padding: 2px; text-align: center'>[Language]</div>";
     } elseif (strstr($str, "CUSTOM")) {
         $cust = preg_replace("/\\W*\\{CUSTOM=(.*?)(\\+.*)?\\}\\W*/si", "\\1", $str);
         echo "<div style='padding: 2px'>[" . $cust . "]</div>";
     } elseif (strstr($str, "CMENU")) {
         $cust = preg_replace("/\\W*\\{CMENU=(.*?)(\\+.*)?\\}\\W*/si", "\\1", $str);
         $this->customMenu[] = $cust;
         echo $tp->parseTemplate("{CMENU=" . $cust . "}", true);
         //	echo $this->renderPanel('Embedded Custom Menu',$cust);
     } elseif (strstr($str, "SETIMAGE")) {
         $cust = preg_replace("/\\W*\\{SETIMAGE(.*?)(\\+.*)?\\}\\W*/si", "\\1", $str);
         echo $tp->parseTemplate("{SETIMAGE" . $cust . "}", true);
         //	echo $this->renderPanel('Embedded Custom Menu',$cust);
     } elseif (strstr($str, "{WMESSAGE")) {
         echo "<div class=text style='padding: 30px; text-align: center'>[Welcome Message Area]</div>";
         //	echo $this->renderPanel('Embedded Custom Menu',$cust);
     } elseif (strstr($str, "{FEATUREBOX")) {
         echo "<div class=text style='padding: 80px; text-align: center'>[Featurebox Area]</div>";
         //	echo $this->renderPanel('Embedded Custom Menu',$cust);
     } else {
         if (strstr($str, "PLUGIN")) {
             $plug = preg_replace("/\\{PLUGIN=(.*?)\\}/si", "\\1", $str);
             $plug = trim($plug);
             if (file_exists(e_PLUGIN . "{$plug}/{$plug}_config.php")) {
                 $link = e_PLUGIN . "{$plug}/{$plug}_config.php";
             }
             if (file_exists(e_PLUGIN . $plug . "/config.php")) {
                 $link = e_PLUGIN . $plug . "/config.php";
             }
             //	$plugtext = "<div class='menu-panel'>";
             //	$plugtext .= "<div class='menu-panel-header' title=\"".MENLAN_34."\">".$plug."</div>";
             $plugtext = $link ? "(" . MENLAN_34 . ":<a href='{$link} btn-menu' title='" . LAN_CONFIGURE . "'>" . LAN_CONFIGURE . "</a>)" : "";
             //	$plugtext .= "</div>";
             echo "<br />";
             echo $this->renderPanel($plug, $plugtext);
             // $ns->tablerender($plug, $plugtext);
         } else {
             if (strstr($str, "MENU")) {
                 $matches = array();
                 if (preg_match_all("/\\{MENU=([\\d]{1,3})(:[\\w\\d]*)?\\}/", $str, $matches)) {
                     $menuText = "";
                     foreach ($matches[1] as $menu) {
                         $menu = preg_replace("/\\{MENU=(.*?)(:.*?)?\\}/si", "\\1", $str);
                         if (isset($sc_style['MENU']['pre']) && strpos($str, 'ret') !== false) {
                             $menuText .= $sc_style['MENU']['pre'];
                         }
                         // ---------------
                         $menuText .= "\n\n<!-- START AREA " . $menu . " -->";
                         $menuText .= "<div id='start-area-" . $menu . "' class='menu-panel'>";
                         $menuText .= "<div class='menu-panel-header' >" . MENLAN_14 . "  " . $menu . "</div>\n\n";
                         $sql9 = new db();
                         //	$sql9 = e107::getDb('sql9');
                         if ($sql9->count("menus", "(*)", " WHERE menu_location='{$menu}' AND menu_layout = '" . $this->dbLayout . "' ")) {
                             unset($text);
                             $menuText .= $rs->form_open("post", e_SELF . "?configure=" . $this->curLayout, "frm_menu_" . intval($menu));
                             $MODE = 1;
                             $sql9->select("menus", "*", "menu_location='{$menu}' AND menu_layout='" . $this->dbLayout . "' ORDER BY menu_order");
                             $menu_count = $sql9->db_Rows();
                             $cl = $this->dragDrop ? "'portlet" : "regularMenu";
                             $menuText .= "\n<div class='column' id='area-" . $menu . "'>\n\n";
                             while ($row = $sql9->fetch(MYSQL_ASSOC)) {
                                 $menuText .= "\n\n\n <!-- Menu Start " . $row['menu_name'] . "-->\n";
                                 $menuText .= "<div class='{$cl}' id='block-" . $row['menu_id'] . "-" . $menu . "'>\n";
                                 //	echo "<div class='ggportal'>";
                                 //	$menuText .= "hi there";
                                 $menuText .= $this->menuRenderMenu($row, $menu_count);
                                 //	echo "\n</div>";
                                 $menuText .= "\n</div>\n";
                                 $menuText .= "<!-- Menu end -->\n\n\n";
                                 // echo "<div><br /></div>";
                             }
                             $menuText .= "\n\n</div>\n\n";
                             // End Column
                             $menuText .= $rs->form_close();
                         } else {
                             // placeholder
                             $menuText .= "<div class='column' id='area-" . $menu . "'><!-- --></div>";
                         }
                         $menuText .= "</div><!-- END OF AREA -->\n\n";
                         // ---------------
                         if (isset($sc_style['MENU']['post']) && strpos($str, 'ret') !== false) {
                             $menuText .= $sc_style['MENU']['post'];
                         }
                     }
                 }
                 $ns->tablerender('', $menuText);
             } else {
                 echo $tp->parseTemplate($str, true);
             }
         }
     }
 }
Exemplo n.º 8
0
        if (post("N")) {
            redirect("/admin/floor.php");
            die("已取消操作!!");
        }
        $id = post("id");
        $A = new db();
        $B = new db();
        $msg = '0';
        if (post("Y")) {
            $A->query("delete from floors where id = '{$id}'") ?: $A->error();
            $B->query("delete from reserves where floor = '{$id}'");
            redirect("/admin/floor.php");
            die("已刪除");
        }
        $B->query("select * from reserves where floor='{$id}'");
        if ($B->count() > 0) {
            while ($B->fetch()) {
                if ($msg == '0') {
                    ?>
                <table border=2>
					<tr>
						<th>預約單編號</th><th>使用日期<br>(年/月/日)</th><th>使用時段</th><th>會議室號碼</th><th>借用人</th>
					</tr>
                <?php 
                }
                ?>
                <tr>
                <td><?php 
                echo $B->element("serial");
                ?>
</td>