本文整理汇总了PHP中DataBase::getinstance方法的典型用法代码示例。如果您正苦于以下问题:PHP DataBase::getinstance方法的具体用法?PHP DataBase::getinstance怎么用?PHP DataBase::getinstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataBase
的用法示例。
在下文中一共展示了DataBase::getinstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showlist
protected function showlist()
{
if (isset(Vars::$get['page'])) {
$page = Page::getinstance(Vars::$get['page']);
$smarty = $this->getSmarty();
$smarty->assign('pagename', $page->getpagename());
$smarty->assign('list', $page->getbackup());
$ret['title'] = $page->getpagename() . ' のバックアップ一覧';
$ret['body'] = $smarty->fetch('list.tpl.htm');
$ret['pagename'] = $page->getpagename();
} else {
$db = DataBase::getinstance();
$query = "SELECT DISTINCT pagename FROM pagebackup ORDER BY pagename ASC";
$result = $db->query($query);
$list = array();
while ($row = $db->fetch($result)) {
$list[] = $row['pagename'];
}
$smarty = $this->getSmarty();
$smarty->assign('list', $list);
$ret['title'] = 'バックアップ一覧';
$ret['body'] = $smarty->fetch('alllist.tpl.htm');
}
return $ret;
}
示例2: do_block
function do_block($pagename, $param1, $param2)
{
$param = array_map('trim', explode(',', $param1));
if (!isset($param[0])) {
throw new PluginException('引数がありません', $this);
}
$url = $param[0];
$expire = isset($param[1]) ? (int) $param[1] : 1;
if ($expire == 0) {
return $this->getrss($url);
} else {
$db = DataBase::getinstance();
$db->begin();
$_url = $db->escape($url);
$row = $db->fetch($db->query("SELECT data,time FROM plugin_rss WHERE url = '{$_url}'"));
if ($row == false || $row['time'] + $expire * 60 < time()) {
$data = $this->getrss($url);
$_data = $db->escape($data);
$query = "INSERT OR REPLACE INTO plugin_rss (url,data,time)";
$query .= " VALUES('{$_url}', '{$_data}', " . time() . ")";
$db->query($query);
} else {
$data = $row['data'];
}
$db->commit();
return $data;
}
}
示例3: do_block
function do_block($page, $param1, $param2)
{
$prefix = resolvepath(trim($param1));
if ($prefix == '') {
$prefix = $page->getpagename();
}
$prefix .= '/';
$db = DataBase::getinstance();
$query = "SELECT pagename FROM page";
$query .= " WHERE pagename like '{$prefix}%'";
$query .= " ORDER BY pagename ASC";
$result = $db->query($query);
$list = array();
while ($row = $db->fetch($result)) {
$list[] = $row['pagename'];
}
if ($list == array()) {
return '';
}
natsort($list);
$len = strlen($prefix);
foreach ($list as $pagename) {
$link[] = '<li>' . makelink(Page::getinstance($pagename), substr($pagename, $len)) . '</li>';
}
return "<ul>\n" . join("\n", $link) . "\n</ul>\n";
}
示例4: kino1tokino2
protected function kino1tokino2()
{
set_time_limit(0);
$unconverted = array();
$db = DataBase::getinstance();
$db->begin();
$_path = $db->escape(realpath(DATA_DIR . WIKIID . '.db.kino1'));
$db->exec("ATTACH DATABASE '{$_path}' as kino1");
$query = 'SELECT pagename FROM kino1.page';
$query .= ' WHERE pagename IN (SELECT pagename FROM purepage)';
$unconverted = $db->fetchsinglearray($db->query($query));
$query = 'INSERT INTO purepage';
$query .= ' SELECT pagename, NULL, source, timestamp, timestamp FROM kino1.page';
$query .= ' WHERE pagename NOT IN (SELECT pagename FROM purepage)';
$db->exec($query);
AutoLink::getinstance()->refresh();
$db->exec('DELETE FROM pagebackup');
$query = 'SELECT main.attach.pagename, main.attach.filename FROM attach';
$query .= ' INNER JOIN kino1.attach ON main.attach.pagename = kino1.attach.pagename AND main.attach.filename = kino1.attach.filename';
$result = $db->query($query);
while ($row = $db->fetch($result)) {
$unconverted[] = "{$row['main.attach.pagename']} の添付ファイル {$row['main.attach.filename']}";
}
$query = 'INSERT OR IGNORE INTO attach';
$query .= ' SELECT * FROM kino1.attach';
$db->exec($query);
$db->commit();
$db->exec("DETACH DATABASE kino1");
return $unconverted;
}
示例5: do_block
function do_block($page, $param1, $param2)
{
if (!mb_ereg('^\\s*(.+?)\\s*,\\s*(\\d+)\\s*$', $param1, $m) || $m[2] <= 0) {
throw new PluginException('引数が正しくありません。', $this);
}
$home = $m[1];
$num = $m[2];
$p = isset(Vars::$get['p']) ? max(0, Vars::$get['p']) : 0;
$point = $num * $p;
$db = DataBase::getinstance();
$pattern = $db->escape('^' . mb_ereg_quote($home) . '/(\\d+)/.+$');
$query = "SELECT pagename,source FROM page";
$query .= " WHERE php('mb_ereg', '{$pattern}', pagename)";
$query .= " ORDER BY timestamp DESC";
$query .= " LIMIT {$num} OFFSET {$point}";
$result = $db->query($query);
$ret = array();
while ($row = $db->fetch($result)) {
$ret[] = $this->includepage($row['pagename'], $row['source'], $home);
}
$smarty = $this->getSmarty();
$smarty->assign('pagename', $page->getpagename());
if ($p > 0) {
$smarty->assign('next', $p - 1);
}
$smarty->assign('prev', $p + 1);
$smarty->assign('body', join("\n", $ret));
return $smarty->fetch('bbsviewer.tpl.htm');
}
示例6: doing
function doing()
{
$db = DataBase::getinstance();
$db->begin();
if (!$db->istable('plugin_counter')) {
$db->exec(file_get_contents(PLUGIN_DIR . 'counter/counter.sql'));
}
$_pagename = $db->escape($this->getcurrentPage()->getpagename());
$query = "SELECT total,today,yesterday,date FROM plugin_counter";
$query .= " WHERE pagename = '{$_pagename}'";
$count = $db->fetch($db->query($query));
$time = time();
$date = date('Y-m-d', $time);
if ($count == null || $date != $count['date']) {
$yesterday = date('Y-m-d', $time - 24 * 60 * 60);
$count['total'] = isset($count['total']) ? $count['total'] + 1 : 1;
$count['yesterday'] = isset($count['date']) && $count['date'] == $yesterday ? $count['today'] : 0;
$count['today'] = 1;
$query = "INSERT OR REPLACE INTO plugin_counter";
$query .= " (pagename, total, today, yesterday, date)";
$query .= " VALUES('{$_pagename}', {$count['total']}, {$count['today']}, {$count['yesterday']}, '{$date}')";
} else {
$count['total']++;
$count['today']++;
$query = "UPDATE plugin_counter";
$query .= " SET total = total + 1, today = today + 1";
$query .= " WHERE pagename = '{$_pagename}'";
}
$db->query($query);
self::$count = $count;
$db->commit();
}
示例7: do_url
public function do_url()
{
$num = isset(Vars::$get['recent']) && Vars::$get['recent'] > 0 ? (int) Vars::$get['recent'] : 15;
$db = DataBase::getinstance();
$query = "SELECT pagename,timestamp FROM page";
if (isset(Vars::$get['exp']) && trim(Vars::$get['exp']) != '') {
$_inc = $db->escape(Vars::$get['exp']);
$query .= " WHERE php('mb_ereg', '{$_inc}', pagename)";
} else {
if (isset(Vars::$get['include']) && trim(Vars::$get['include']) != '') {
$_inc = $db->escape(glob2ereg(Vars::$get['include']));
$query .= " WHERE php('mb_ereg', '{$_inc}', pagename)";
}
}
$query .= " ORDER BY timestamp DESC, pagename ASC LIMIT {$num}";
$result = $db->query($query);
$list = array();
while ($row = $db->fetch($result)) {
$item['timestamp'] = $row['timestamp'];
$item['pagename'] = $row['pagename'];
$item['url'] = getURL(Page::getinstance($row['pagename']));
$list[] = $item;
}
$smarty = $this->getSmarty();
$smarty->assign('rssurl', SCRIPTURL . '?' . htmlspecialchars($_SERVER['QUERY_STRING']));
$smarty->assign('sitename', SITENAME);
$smarty->assign('baseurl', SCRIPTURL);
$smarty->assign('list', $list);
header('Content-Type: application/xml; charset=UTF-8');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $item['timestamp'][0]) . ' GMT');
$smarty->display('rss10.tpl.htm');
exit;
}
示例8: do_url
function do_url()
{
if (!keys_exists(Vars::$post, 'base', 'config')) {
throw new PluginException('パラメータが足りません', $this);
}
$source = Page::getinstance(':config/plugin/tracker/' . Vars::$post['config'] . '/page')->getsource();
foreach (Vars::$post as $key => $data) {
if (mb_strpos($key, 'param_') === 0) {
$name = '[' . mb_substr($key, 6) . ']';
$_data = trim($data);
$_data = mb_ereg_replace('\\[', '[', $_data, 'm');
$_data = mb_ereg_replace('\\]', ']', $_data, 'm');
$replace[$name] = $_data;
}
}
$replace['[_date]'] = date('Y-m-d H:i:s');
$replace['[_base]'] = Vars::$post['base'];
foreach ($replace as $name => $data) {
$source = mb_ereg_replace(mb_ereg_quote($name), $data, $source, 'm');
}
$db = DataBase::getinstance();
self::$sqlite_pattern = '^' . mb_ereg_quote(Vars::$post['base']) . '/(\\d+)';
$db->create_aggregate('plugin_tracker_maxnum', array('Plugin_tracker', 'sqlite_maxnum'), array('Plugin_tracker', 'sqlite_maxnum_finalize'), 1);
$row = $db->fetch($db->query("SELECT plugin_tracker_maxnum(pagename) FROM page"));
$num = $row[0] + 1;
$title = isset(Vars::$post['param_title']) && trim(Vars::$post['param_title']) != '' ? '/' . trim(Vars::$post['param_title']) : '';
$page = Page::getinstance(Vars::$post['base'] . '/' . $num . $title);
$page->write($source);
redirect($page);
}
示例9: do_url
public function do_url()
{
if (!isset(Vars::$get['blogname']) || trim(Vars::$get['blogname']) == '') {
throw new PluginException('パラメータが足りません。', $this);
}
$blogname = trim(Vars::$get['blogname']);
$num = isset(Vars::$get['recent']) && Vars::$get['recent'] > 0 ? (int) Vars::$get['recent'] : 15;
$db = DataBase::getinstance();
$_exp = $db->escape('^' . mb_ereg_quote($blogname) . '/\\d{4}-\\d{2}-\\d{2}/');
$query = "SELECT pagename,timestamp FROM page";
$query .= " WHERE php('mb_ereg', '{$_exp}', pagename)";
$query .= " ORDER BY timestamp DESC, pagename ASC LIMIT {$num}";
$result = $db->query($query);
$list = array();
$prefixsize = mb_strlen($blogname . '/9999-99-99/');
while ($row = $db->fetch($result)) {
$item['timestamp'] = $row['timestamp'];
$item['pagename'] = mb_substr($row['pagename'], $prefixsize);
$item['url'] = getURL(Page::getinstance($row['pagename']));
$list[] = $item;
}
$smarty = $this->getSmarty();
$smarty->assign('rssurl', SCRIPTURL . '?' . htmlspecialchars($_SERVER['QUERY_STRING']));
$smarty->assign('sitename', SITENAME);
$smarty->assign('blogurl', getURL(Page::getinstance($blogname)));
$smarty->assign('blogname', $blogname);
$smarty->assign('list', $list);
header('Content-Type: application/xml; charset=UTF-8');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $item['timestamp'][0]) . ' GMT');
$smarty->display('blogrss10.tpl.htm');
exit;
}
示例10: do_block
function do_block($page, $param1, $param2)
{
$num = (int) trim($param1) > 0 ? (int) trim($param1) : 15;
$exp = array();
foreach (array_map('trim', explode("\n", $param2)) as $s) {
if ($s != '') {
$exp[] = $s;
}
}
$db = DataBase::getinstance();
$query = "SELECT pagename,timestamp FROM page";
if ($exp != array()) {
$_exp = $db->escape('(?:' . join('|', $exp) . ')');
$query .= " WHERE php('mb_ereg', '{$_exp}', pagename) = 0";
}
$query .= " ORDER BY timestamp DESC, pagename ASC LIMIT {$num}";
$result = $db->query($query);
$list = array();
while ($row = $db->fetch($result)) {
$list[date('Y-m-d', $row['timestamp'])][] = makelink(Page::getinstance($row['pagename']));
}
$smarty = $this->getSmarty();
$smarty->assign('list', $list);
return $smarty->fetch('recent.tpl.htm');
}
示例11: do_url
function do_url()
{
$db = DataBase::getinstance();
$list = $db->fetchsinglearray($db->query('SELECT pagename FROM page'));
mb_natcasesort($list);
$smarty = $this->getSmarty();
$smarty->assign('pagelist', $list);
$ret['title'] = 'ページ一覧';
$ret['body'] = $smarty->fetch('list.tpl.htm');
return $ret;
}
示例12: do_block
function do_block($page, $param1, $param2)
{
$smarty = $this->getSmarty();
$db = DataBase::getinstance();
$query = "SELECT pagename, count(linker) AS pagecount, sum(times) AS total";
$query .= " FROM page LEFT JOIN linklist ON linked = pagename";
$query .= " GROUP BY pagename";
$query .= " ORDER BY pagecount DESC, total DESC, pagename ASC";
$result = $db->query($query);
while ($row = $db->fetch($result)) {
$smarty->append('list', $row);
}
return $smarty->fetch('list.tpl.htm');
}
示例13: puki2kino
protected function puki2kino()
{
set_time_limit(0);
$unconverted = array();
$db = DataBase::getinstance();
$db->begin();
$dir = opendir(DATA_DIR . 'wiki');
while (($filename = readdir($dir)) !== false) {
$path = DATA_DIR . 'wiki/' . $filename;
if (!is_file($path) || !preg_match('/^(.+)\\.txt$/', $filename, $m)) {
continue;
}
$eucname = substr(pack('H*', '20202020' . $m[1]), 4);
$pagename = mb_convert_encoding($eucname, 'UTF-8', 'EUC-JP');
$_pagename = $db->escape($pagename);
$_source = $db->escape(mb_convert_encoding(file_get_contents($path), 'UTF-8', 'EUC-JP'));
$query = "INSERT OR IGNORE INTO purepage";
$query .= " VALUES('{$_pagename}', null, '{$_source}'," . time() . "," . time() . ")";
$db->query($query);
if ($db->changes() == 0) {
$unconverted[] = $pagename;
}
}
AutoLink::getinstance()->refresh();
$dir = opendir(DATA_DIR . 'attach');
while (($filename = readdir($dir)) !== false) {
$path = DATA_DIR . 'attach/' . $filename;
if (!is_file($path) || !preg_match('/^([0-9A-F]+)_([0-9A-F]+)$/', $filename, $m)) {
continue;
}
$eucname = substr(pack('H*', '20202020' . $m[1]), 4);
$pagename = mb_convert_encoding($eucname, 'UTF-8', 'EUC-JP');
$eucfilename = substr(pack('H*', '20202020' . $m[2]), 4);
$filename = mb_convert_encoding($eucfilename, 'UTF-8', 'EUC-JP');
$_pagename = $db->escape($pagename);
$_filename = $db->escape($filename);
$bin = file_get_contents($path);
$_data = $db->escape($bin);
$_size = strlen($bin);
$query = "INSERT OR IGNORE INTO attach";
$query .= " (pagename, filename, binary, size, timestamp, count)";
$query .= " VALUES('{$_pagename}', '{$_filename}', '{$_data}', {$_size}, " . time() . ", 0)";
$db->query($query);
if ($db->changes() == 0) {
$unconverted[] = "{$pagename} の添付ファイル {$filename}";
}
}
$db->commit();
return $unconverted;
}
示例14: __construct
protected function __construct($home)
{
$this->home = $home;
$db = DataBase::getinstance();
$_pattern = $db->escape('^' . mb_ereg_quote($home) . '/\\d{4}-\\d{2}-\\d{2}$');
$query = "SELECT pagename FROM page";
$query .= " WHERE php('mb_ereg', '{$_pattern}', pagename)";
$result = $db->query($query);
$this->datepage = array();
while ($row = $db->fetch($result)) {
$this->datepage[] = $row['pagename'];
}
sort($this->datepage);
}
示例15: do_block
function do_block($page, $param1, $param2)
{
$arg = array_map('trim', explode(',', $param1));
$base = isset($arg[0]) && $arg[0] != '' ? $arg[0] : $page->getpagename();
$config = isset($arg[1]) && $arg[1] != '' ? $arg[1] : 'default';
$this->sortkey = isset($arg[2]) ? array_slice($arg, 2) : array();
$configpagename = ':config/plugin/tracker/' . $config;
$configdata = Plugin_tracker::Page2data(Page::getinstance($configpagename));
$this->type2name = array();
foreach ($configdata['form'] as $name => $line) {
if (mb_ereg('\\[(.+?)\\]', $line[0], $m)) {
$this->type2name[$m[1]] = $name;
}
}
$this->selectorder = $this->getselectorderlist($configdata);
$bgcolorlist = $this->getbgcolorlist($configdata);
$list = array();
$db = DataBase::getinstance();
$query = 'SELECT pagename, source FROM page';
$query .= ' WHERE pagename like \'' . $db->escape($base) . '%\'';
$query .= ' ORDER BY timestamp DESC';
$result = $db->query($query);
while ($row = $db->fetch($result)) {
if (!mb_ereg('^' . mb_ereg_quote($base) . '/(\\d+)/(.+)$', $row[0], $m)) {
continue;
}
$item = array();
$item['var']['_page'] = $row[0];
$item['var']['_num'] = $m[1];
$item['var']['_title'] = $m[2];
foreach (explode("\n", $row[1]) as $line) {
if (mb_ereg('^[-ー・](.+?)[\\t ]*[::][\\t ]*(.+?)[\\t ]*$', $line, $m)) {
if (!isset($item[$m[1]])) {
$item['var'][$m[1]] = $m[2];
$item['bgcolor'][$m[1]] = isset($bgcolorlist[$m[1]][$m[2]]) ? $bgcolorlist[$m[1]][$m[2]] : null;
}
}
}
$list[] = $item;
}
usort($list, array($this, 'cmp'));
$smarty = $this->getSmarty();
$smarty->assign('list', $list);
if (trim($param2) == '') {
return '<p class="warning">表示項目を指定してください</p>';
}
$smarty->assign('varname', array_map('trim', explode(',', $param2)));
return $smarty->fetch('trackerlist.tpl.htm');
}