本文整理汇总了PHP中MySQLDatabase::fetchAssoc方法的典型用法代码示例。如果您正苦于以下问题:PHP MySQLDatabase::fetchAssoc方法的具体用法?PHP MySQLDatabase::fetchAssoc怎么用?PHP MySQLDatabase::fetchAssoc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySQLDatabase
的用法示例。
在下文中一共展示了MySQLDatabase::fetchAssoc方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDataFromDB
/**
* Get settings data from DB.
*
* @access private
* @return array
*/
private function getDataFromDB()
{
$data = array();
$query = $this->db->query("\n\t\t\tSELECT setting_name, setting_value\n\t\t\tFROM ts_system_settings\n\t\t\tORDER BY id\n\t\t");
while (($row = $this->db->fetchAssoc($query)) != NULL) {
$data[$row['setting_name']] = $row['setting_value'];
}
return $data;
}
示例2: getNumPages
/**
* Calculate the number of pages.
*
* @access public
* @return int
*/
public function getNumPages()
{
if ($this->user->ugroup == 1) {
$query = "SELECT COUNT(1) AS total FROM ts_tickets_view WHERE status_name = 'Opened'";
$total = $this->db->fetchAssoc($query);
} else {
$query = "SELECT COUNT(1) AS total FROM ts_tickets_view WHERE author_id = " . $this->db->escapeVal($this->user->id);
$total = $this->db->fetchAssoc($query);
}
$this->totalEntryNum = (int) $total['total'];
$this->numPages = ceil($this->totalEntryNum / $this->entryPerPage);
return $this->numPages;
}
示例3: displayCategories
/**
* Get all available categories.
*
* @access public
* @return array
*/
public function displayCategories()
{
$allCats = $this->db->query("SELECT id, category_name FROM ts_ticket_category ORDER BY id");
$keys = array();
$values = array();
while (($categories = $this->db->fetchAssoc($allCats)) != NULL) {
//array_push($keys, (int)$categories['id']);
//array_push($values, $categories['category_name']);
$keys[] = (int) $categories['id'];
$values[] = $categories['category_name'];
}
return array_combine($keys, $values);
}
示例4: chkUserExistance
/**
* Search for user in database. Check whether user is
* a numeric value, for example user id or is it an array
* of user attributes.
*
* @access public
* @param int | array
* @return array | bool
*/
public function chkUserExistance($user)
{
if (is_numeric($user)) {
$query = "\n\t\t\t\tSELECT id, username, userpass, email, ugroup\n\t\t\t\tFROM ts_users\n\t\t\t\tWHERE id = " . $this->db->escapeVal($user) . "\n\t\t\t\tLIMIT 1\n\t\t\t";
return $query;
} else {
if (is_array($user)) {
$query = "\n\t\t\t\tSELECT id, username, userpass, email, ugroup\n\t\t\t\tFROM ts_users\n\t\t\t\tWHERE username = '" . $this->db->escapeVal($user['username']) . "'\n\t\t\t\tOR email = '" . $this->db->escapeVal($user['email']) . "'\n\t\t\t\tLIMIT 1\n\t\t\t";
# If user not found
if (!($row = $this->db->fetchAssoc($query))) {
return false;
}
return true;
}
}
}