本文整理汇总了PHP中query::count方法的典型用法代码示例。如果您正苦于以下问题:PHP query::count方法的具体用法?PHP query::count怎么用?PHP query::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类query
的用法示例。
在下文中一共展示了query::count方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkLogin
/**
* Check the login data of a user and return true if data is correct or false if incorrect.
* @param string Username
* @param string User's pasword.
* @return boolean true if check was successful or false if not.
*/
function checkLogin($login, $passwd)
{
global $db, $c;
$sql = "SELECT USER_ID FROM users WHERE USER_NAME='{$login}' AND PASSWORD = '{$passwd}'";
$query = new query($db, $sql);
if ($query->count() == 1) {
// login successfull
$query->getrow();
$this->userId = $query->field("USER_ID");
return true;
} else {
return false;
}
$query->free();
}
示例2: getRows
/**
* query the rows from the database
*/
function getRows()
{
global $db, $c, $sid, $lang, $auth;
$result = array();
$order = "ca.TITLE";
if ($this->order == "NAME") {
$order = "ca.TITLE";
} else {
if ($this->order == "CATEGORY") {
$order = "ca.CH_CAT_ID";
} else {
if ($this->order == "EDITED") {
$order = "cv.LAST_CHANGED";
} else {
if ($this->order == "CREATED") {
$order = "cv.CREATED_AT";
} else {
if ($this->order == "POSITION") {
$order = "ca.POSITION";
}
}
}
}
}
$order .= " " . $this->orderdir;
// $sql_articles = "Select ca.*, cv.LAST_USER, cv.CREATED_AT, cv.LAST_CHANGED FROM channel_articles ca, cluster_variations cv ".$this->getFilterJoin()." WHERE ca.CHID = ".$this->channelId." AND ca.ARTICLE_ID = cv.CLNID AND cv.VARIATION_ID = ".variation()." AND ca.VERSION=0 " . $this->getFilterSQL() . " ORDER BY $order LIMIT ".(($this->page - 1) * $this->recordsPerPage).",".$this->recordsPerPage;
$sql_articles = "SELECT DISTINCT ca.* FROM channel_articles ca, cluster_variations cv " . $this->getFilterJoin() . " WHERE ca.ARTICLE_ID = cv.CLNID AND ca.CHID = " . $this->channelId . " AND ca.VERSION = 0 " . $this->getFilterSQL() . " ORDER BY {$order} LIMIT " . ($this->page - 1) * $this->recordsPerPage . "," . $this->recordsPerPage;
// echo $sql_articles;
$query = new query($db, $sql_articles);
while ($query->getrow()) {
$tmp = array();
$varexists = true;
$article_id = $query->field("ARTICLE_ID");
$cvdatasql = "SELECT * FROM cluster_variations WHERE CLNID = " . $article_id . " AND VARIATION_ID=" . variation();
$cvdata = new query($db, $cvdatasql);
$cvdata->getrow();
if ($cvdata->count() < 1) {
$varexists = false;
}
array_push($tmp, $query->field("ARTICLE_ID"));
$clid = getDBCell("cluster_variations", "CLID", "CLNID = " . $query->field("ARTICLE_ID") . " AND VARIATION_ID = " . variation());
$live = isClusterLive($clid);
if ($varexists) {
if ($live) {
array_push($tmp, drawImage("green.gif", $lang->get("article_is_live", "Article is live")));
} else {
array_push($tmp, drawImage("red.gif", $lang->get("article_is_expired", "Article is expired")));
}
} else {
array_push($tmp, drawImage("gray.gif", $lang->get("article_variation_missing", "Variation of this article does not exist yet")));
}
array_push($tmp, $query->field("POSITION"));
array_push($tmp, '<b>' . $query->field("TITLE") . '</b>');
array_push($tmp, $this->categories[$query->field("CH_CAT_ID")]);
array_push($tmp, formatDBTimestamp($cvdata->field("LAST_CHANGED")));
$buttons = " " . crLink(drawImage('up.gif'), $c["docroot"] . "modules/channels/overview.php?sid={$sid}&action=up&article=" . $query->field("ARTICLE_ID"), "navelement");
$buttons .= " " . crLink(drawImage('down.gif'), $c["docroot"] . "modules/channels/overview.php?sid={$sid}&action=down&article=" . $query->field("ARTICLE_ID"), "navelement");
$buttons .= " ";
if ($auth->checkAccessToFunction("CHANNEL_DELETE")) {
$buttons .= " " . crLink($lang->get("delete"), "javascript:confirmAction('" . $lang->get("del_article") . "', '" . $c["docroot"] . "modules/channels/overview.php?sid={$sid}&action=deletearticle&article=" . $query->field("ARTICLE_ID") . "');", "navelement");
}
if ($auth->checkAccessToFunction("CHANNEL_LAUNCH")) {
$buttons .= " " . crLink($lang->get("launch", "Launch"), $c["docroot"] . "modules/channels/overview.php?sid={$sid}&action=launcharticle&article=" . $query->field("ARTICLE_ID"), "navelement");
$buttons .= " " . crLink($lang->get("expire", "Expire"), $c["docroot"] . "modules/channels/overview.php?sid={$sid}&action=expirearticle&article=" . $query->field("ARTICLE_ID"), "navelement");
}
array_push($tmp, $buttons);
array_push($result, $tmp);
}
return $result;
}
示例3: copyRow
/**
* Copies a row an replaces specified values
* if translate is specified as value, the given id will be translated to a live id.
*
* @param string Name of table in which row shall be copied
* @param string Filter to apply on table to select record(s)
* @param array array[n]["column"]: Column to replace, array[n]["value"]: Value to set, array[n]["datatype"]: type of data (NUMBER|CHAR|DATE)
*/
function copyRow($table, $filter, $values) {
global $db, $c_datatypes, $panic;
$sql = "SELECT * FROM $table WHERE $filter";
$query = new query($db, $sql);
for ($i = 0; $i < $query->count(); $i++) {
$row = $query->getrow();
$newRec = new CreateSet($table);
$columns = $db->ADODB->MetaColumns($table);
if (!is_array($columns)) return false;
foreach ($columns as $name=>$obvalue) {
$value[$n] = $query->field($name);
foreach ($values as $vcol => $vval) {
if ($name == $vcol) {
if (sameText($vval, "translate")) {
if (is_numeric($value[$n]) && ($value[$n] != "0"))
$value[$n] = translateState($value[$n], 10, false);
} else {
$value[$n] = $vval;
}
}
}
$column[$n] = $name;
$newRec->add($column[$n], $value[$n], $c_datatypes[$table][$name]);
}
$newRec->execute();
}
}
示例4: is_plugin_installed
/**
* This function returns if a plugin is installed.
* It's used, if a new plugin or a designed website require_onces a certain plugin.
* @param string The name of the desired plugin.
* @returns int the version number if installed, otherwise false
*/
function is_plugin_installed($name)
{
global $db;
$sql = "SELECT VERSION FROM modules WHERE MODULE_NAME = '{$name}'";
$query = new query($db, $sql);
$amount = $query->count();
if ($amount > 0) {
$query->getrow();
$version = $query->field("VERSION");
}
$query->free();
return $amount > 0 ? $version : false;
}