本文整理匯總了PHP中MySql::getInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP MySql::getInstance方法的具體用法?PHP MySql::getInstance怎麽用?PHP MySql::getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MySql
的用法示例。
在下文中一共展示了MySql::getInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getInstance
public static function getInstance()
{
switch (Option::DEFAULT_MYSQLCONN) {
case 'mysqli':
return MySqlii::getInstance();
break;
case 'mysql':
default:
return MySql::getInstance();
break;
}
}
示例2: getInstance
public static function getInstance()
{
if (class_exists('mysqli', FALSE)) {
return MySqlii::getInstance();
} else {
if (class_exists('mysql', FALSE)) {
return MySql::getInstance();
} else {
emMsg('服務器空間PHP不支持MySql數據庫');
}
}
}
示例3: getDbInstance
/**
* 獲取Db實例
* @param null
*/
public function getDbInstance()
{
if (!is_null($this->_db)) {
return $this->_db;
}
if (class_exists('mysqli')) {
$this->_db = MySqlii::getInstance();
} else {
$this->_db = MySql::getInstance();
}
return $this->_db;
}
示例4: asc_time_limit
function asc_time_limit($ip, $time_limit)
{
$DB = MySql::getInstance();
if ($time_limit <= 0) {
return;
}
$time_line = time() - $time_limit;
$sql = "SELECT ip FROM " . DB_PREFIX . "comment WHERE ip='{$ip}' AND date > {$time_line}";
$query = $DB->query($sql);
$num = $DB->num_rows($query);
if ($num) {
ascMsg("{$time_limit}秒內隻能發表一次評論,評論發表失敗");
}
}
示例5: __construct
public function __construct()
{
if (is_null(self::$DbHandler)) {
if (class_exists('mysqli')) {
self::$DbHandler = MySqlii::getInstance();
} else {
self::$DbHandler = MySql::getInstance();
}
}
$this->tableName = DB_PREFIX . $this->tableName;
$this->fields = $this->getDbFields();
foreach ($this->fields as $key => $value) {
$this->SQLfields .= $this->parseKey($value) . ',';
}
$this->SQLfields = rtrim($this->SQLfields, ',');
#查詢的全字段預處理
}
示例6: getSmallImg
function getSmallImg($gid)
{
$db = MySql::getInstance();
$sql = "SELECT excerpt FROM " . DB_PREFIX . "blog WHERE checked='y' and password='' and gid=" . $gid;
$query = $db->query($sql);
while ($row = $db->fetch_array($query)) {
preg_match_all("/<img([^>]+)src=\"([^>\"]+)\"?([^>]*)>/i", $row['excerpt'], $matches);
//從摘要找縮略圖
if ($matches[2][1]) {
//$imgsrc=$matches[2][1]?$matches[2][1]:$matches[2][0];
$imgsrc = $matches[2][1];
} else {
$imgsrc = TEMPLATE_URL . "img/bgtest.png";
}
}
return $imgsrc;
}
示例7: getBlog
/**
* 獲取文章信息
*
* @return array
*/
function getBlog($sortid = null)
{
$DB = MySql::getInstance();
$sorts = Cache::getInstance()->readCache('sort');
if (isset($sorts[$sortid])) {
$sort = $sorts[$sortid];
if ($sort['pid'] != 0 || empty($sort['children'])) {
$subsql = "and sortid={$sortid}";
} else {
$sortids = array_merge(array($sortid), $sort['children']);
$subsql = "and sortid in (" . implode(',', $sortids) . ")";
}
} else {
$subsql = $sortid ? "and sortid={$sortid}" : '';
}
$sql = "SELECT * FROM " . DB_PREFIX . "blog WHERE hide='n' and type='blog' {$subsql} ORDER BY date DESC limit 0," . Option::get('rss_output_num');
$result = $DB->query($sql);
$blog = array();
while ($re = $DB->fetch_array($result)) {
$re['id'] = $re['gid'];
$re['title'] = htmlspecialchars($re['title']);
$re['date'] = $re['date'];
$re['content'] = $re['content'];
if (!empty($re['password'])) {
$re['content'] = '<p>[該文章已設置加密]</p>';
} elseif (Option::get('rss_output_fulltext') == 'n') {
if (!empty($re['excerpt'])) {
$re['content'] = $re['excerpt'];
} else {
$re['content'] = extractHtmlData($re['content'], 330);
}
$re['content'] .= ' <a href="' . Url::log($re['id']) . '">閱讀全文>></a>';
}
$blog[] = $re;
}
return $blog;
}
示例8: img_fj
function img_fj($blogid)
{
$db = MySql::getInstance();
$sql = "SELECT * FROM " . DB_PREFIX . "attachment WHERE blogid=" . $blogid . " AND (`filepath` LIKE '%jpg' OR `filepath` LIKE '%gif' OR `filepath` LIKE '%png') ORDER BY `aid` ASC LIMIT 0,1";
$imgs = $db->query($sql);
$img_path = "";
while ($row = $db->fetch_array($imgs)) {
$img_path .= BLOG_URL . substr($row['filepath'], 3, strlen($row['filepath']));
}
return $img_path;
}
示例9: dbConnect
/**
* 書簽函數集合
*/
function dbConnect()
{
include "copy/mysql.php";
$result = MySql::getInstance();
return $result;
}
示例10: echo_levels
function echo_levels($comment_author_email, $comment_author_url)
{
$DB = MySql::getInstance();
$vip_list = array('"2398112878@qq.com"');
if (in_array($comment_author_email, $vip_list)) {
echo '<a class="vip" href="mailto:2398112878@qq.com" title="會員認證"></a>';
}
$adminEmail = '"infreesu@hotmail.com"';
if ($comment_author_email == $adminEmail) {
echo '<a class="vip" href="mailto:' . $comment_author_email . '" title="作者認證"></a>';
echo '<a class="vp" href="mailto:infreesu@hotmail.com" title="管理員認證"></a><a class="vip7" title="特別認證"></a>';
}
$sql = "SELECT cid as author_count FROM emlog_comment WHERE mail = " . $comment_author_email;
$res = $DB->query($sql);
$author_count = mysql_num_rows($res);
if ($author_count >= 5 && $author_count < 10 && $comment_author_email != $adminEmail) {
echo '<a class="vip1" title="路過醬油 LV.1"></a>';
} else {
if ($author_count >= 10 && $author_count < 20 && $comment_author_email != $adminEmail) {
echo '<a class="vip2" title="偶爾光臨 LV.2"></a>';
} else {
if ($author_count >= 20 && $author_count < 40 && $comment_author_email != $adminEmail) {
echo '<a class="vip3" title="常駐人口 LV.3"></a>';
} else {
if ($author_count >= 40 && $author_count < 80 && $comment_author_email != $adminEmail) {
echo '<a class="vip4" title="以博為家 LV.4"></a>';
} else {
if ($author_count >= 80 && $author_count < 160 && $comment_author_email != $adminEmail) {
echo '<a class="vip5" title="情牽小博 LV.5"></a>';
} else {
if ($author_count >= 160 && $author_coun < 320 && $comment_author_email != $adminEmail) {
echo '<a class="vip6" title="為博終老 LV.6"></a>';
} else {
if ($author_count >= 320 && $comment_author_email != $adminEmail) {
echo '<a class="vip7" title="三世情牽 LV.7"></a>';
}
}
}
}
}
}
}
}
示例11: dataBak
/**
* 備份數據庫結構和所有數據
*
* @param string $table 數據庫表名
* @return string
*/
function dataBak($table)
{
$DB = MySql::getInstance();
$sql = "DROP TABLE IF EXISTS {$table};\n";
$createtable = $DB->query("SHOW CREATE TABLE {$table}");
$create = $DB->fetch_row($createtable);
$sql .= $create[1] . ";\n\n";
$rows = $DB->query("SELECT * FROM {$table}");
$numfields = $DB->num_fields($rows);
$numrows = $DB->num_rows($rows);
while ($row = $DB->fetch_row($rows)) {
$comma = '';
$sql .= "INSERT INTO {$table} VALUES(";
for ($i = 0; $i < $numfields; $i++) {
$sql .= $comma . "'" . $DB->escape_string($row[$i]) . "'";
$comma = ',';
}
$sql .= ");\n";
}
$sql .= "\n";
return $sql;
}
示例12: plugin_setting_view
function plugin_setting_view()
{
$DB = MySql::getInstance();
$ActMe = isset($_GET['downAct']) ? addslashes($_GET['downAct']) : NULL;
$Page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$DownList = DownloadMe_Ret("SQL");
$File_Unu = 0;
$File_Out = 0;
$File_Web = 0;
$Page_Num = 12;
if (!empty($DownList['File'])) {
foreach ($DownList['File'] as $Key => $Val) {
$Set = $Val['download'] ? unserialize($Val['download']) : array("statis" => 0, "hide" => false, "web" => false);
$Val['md5'] = $Val['blogid'] . '-' . $Val['aid'];
if ($Set['hide'] === true) {
$File_Out++;
}
if ($Set['web'] === true) {
$File_Web++;
}
if (DownloadMe_File($Val['filepath']) === false && $Set['web'] !== true) {
$File_Unu++;
}
if (!empty($ActMe) && $ActMe == "web" && $Set['web'] === true) {
$ListEcho[] = $Val;
}
if (!empty($ActMe) && $ActMe == "out" && $Set['hide'] === true) {
$ListEcho[] = $Val;
}
if (!empty($ActMe) && $ActMe == "unu" && DownloadMe_File($Val['filepath']) === false && $Set['web'] !== true) {
$ListEcho[] = $Val;
}
if (empty($ActMe)) {
$ListEcho[] = $Val;
}
}
}
$PageMe = pagination(count($ListEcho), $Page_Num, $Page, './plugin.php?plugin=download' . ($ActMe ? '&downAct=' . $ActMe : '') . '&page=');
?>
<div class="DownloadMe">
<div class="Title"><b>附件管理</b> - 就是這麽方便!
<div class="navMe">
<a title="外鏈附件"href="./plugin.php?plugin=download&downAct=web" class="urlimg <?php
echo $ActMe == 'unu' ? 'strong' : '';
?>
">
( <font class="File_Unu"><?php
echo $File_Web;
?>
</font> )</a>
<a title="異常附件" href="./plugin.php?plugin=download&downAct=unu" class="unu <?php
echo $ActMe == 'unu' ? 'strong' : '';
?>
">
( <font class="File_Unu"><?php
echo $File_Unu;
?>
</font> )</a>
<a title="暫停下載" href="./plugin.php?plugin=download&downAct=out" class="out <?php
echo $ActMe == 'out' ? 'strong' : '';
?>
">
( <font class="File_Out"><?php
echo $File_Out;
?>
</font> )</a>
<a title="全部附件" href="./plugin.php?plugin=download" class="anImg start <?php
echo empty($ActMe) ? 'strong' : '';
?>
">
( <font class="File_All"><?php
echo count($DownList['File']);
?>
</font> )</a>
<a href="./plugin.php?plugin=download&downAct=gov" class="anImg config <?php
echo $ActMe == 'gov' ? 'strong' : '';
?>
">
設置</a>
<a href="javascript:FileActMe('UpCache');" class="anImg cache">緩存</a>
<a href="javascript:VersionMe();" class="anImg upload">更新</a>
</div>
</div>
<form action="" method="post" enctype="application/x-www-form-urlencoded">
<div class="List">
<div class="notes">注:
<?php
echo empty($ActMe) ? '在刪除日誌時關聯附件也會被刪除' : '';
?>
<?php
echo $ActMe == 'out' ? '文章頁麵輸出附件列表時, 暫停下載的附件將會被剔除 (不輸出) ..' : '';
?>
<?php
echo $ActMe == 'unu' ? '不存在實體文件, 隻存在數據庫關聯的附件..' : '';
?>
<?php
echo $ActMe == 'gov' ? '停用此插件後配置將有可能會被清空!(取決於緩存文件 "downloadMeData_Inc.php")...' : '';
?>
<?php
echo $ActMe == 'web' ? '網絡上的共享附件,程序不會將附件下載到本地服務器中,隻做下載點擊的統計!' : '';
//.........這裏部分代碼省略.........
示例13: DownloadMe_NewUp
function DownloadMe_NewUp($Gid, $Da = false)
{
$DB = MySql::getInstance();
$DownData = DownloadMe_Ret();
$Data = $DownData['File'][$Gid];
if (!empty($Data)) {
$Aid = $Data['aid'];
$Lid = $Data['blogid'];
$Edit = unserialize($Data['download']);
$Edit['statis'] = intval($Edit['statis']) + 1;
$editIF = $DB->query("UPDATE " . DB_PREFIX . "attachment SET download='" . serialize($Edit) . "' WHERE aid={$Aid} AND blogid={$Lid}");
DownloadMe_Up();
if ($Da === false) {
return true;
}
global $CACHE;
$Da[$Gid][] = getIp() . '#' . time();
$CACHE->cacheWrite(serialize($Da), DOWNLOAD_CACHE_NAME . "_Gip");
}
return false;
}
示例14: isset
<div class="content-box">
<!-- Start Content Box -->
<div class="content-box-header">
<h3 style="cursor: s-resize; ">特征列表</h3>
<div class="clear"></div>
</div>
<!-- End .content-box-header -->
<div class="content-box-content">
<div class="tab-content default-tab" id="tab1" style="display: block; ">
<!-- This is the target div. id must match the href of this div's tab -->
<?php
require_once 'define.php';
require_once 'mysql.php';
require_once 'FunctionBase.php';
$mysql = MySql::getInstance();
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
if ($action == 'del' && isset($_REQUEST['id'])) {
$id = $_REQUEST['id'];
$mysql->query("delete from ErrFeature where id='" . $id . "';");
emDirect("FeatureList.php?active_del=true");
}
$rq = $mysql->query('select * from ErrFeature');
?>
<table>
<thead>
<tr>
<th>ID</th>
<th>類型</th>
<th>特征表達式</th>
<th>提示信息</th>
示例15: getUserDataByLogin
/**
* 通過登錄名查詢管理員信息
*
* @param string $userLogin User's username
* @return bool|object False on failure, User DB row object
*/
public static function getUserDataByLogin($userLogin)
{
$DB = MySql::getInstance();
if (empty($userLogin)) {
return false;
}
$userData = false;
if (!($userData = $DB->once_fetch_array("SELECT * FROM " . DB_PREFIX . "user WHERE username = '{$userLogin}'"))) {
return false;
}
$userData['nickname'] = htmlspecialchars($userData['nickname']);
$userData['username'] = htmlspecialchars($userData['username']);
return $userData;
}