本文整理汇总了PHP中db_table函数的典型用法代码示例。如果您正苦于以下问题:PHP db_table函数的具体用法?PHP db_table怎么用?PHP db_table使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_table函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup_hooks
function setup_hooks()
{
global $context, $hooks, $smcFunc;
$integration_function = empty($context['uninstalling']) ? 'add_integration_function' : 'remove_integration_function';
$class = $hooks['class'];
$file = $hooks['file'];
foreach ($hooks['hooks'] as $hook) {
$integration_function($hook, $class . '::' . $hook, $file);
}
if (empty($context['uninstalling'])) {
$db_table = db_table();
$db_table->db_create_table('{db_prefix}notices', array(array('name' => 'id_notice', 'type' => 'int', 'unsigned' => true, 'size' => 10, 'autoincrement' => true), array('name' => 'body', 'type' => 'text'), array('name' => 'class', 'type' => 'varchar', 'size' => 50, 'default' => ''), array('name' => 'expire', 'type' => 'int', 'unsigned' => true, 'size' => 10, 'default' => 0), array('name' => 'added', 'type' => 'int', 'unsigned' => true, 'size' => 10, 'default' => 0), array('name' => 'show_to', 'type' => 'varchar', 'size' => 150, 'default' => ''), array('name' => 'positioning', 'type' => 'varchar', 'size' => 255, 'default' => '')), array(array('name' => 'id_notice', 'type' => 'primary', 'columns' => array('id_notice')), array('name' => 'expire', 'type' => 'key', 'columns' => array('expire'))));
$db_table->db_create_table('{db_prefix}log_notices', array(array('name' => 'id_notice', 'type' => 'int', 'unsigned' => true, 'size' => 10, 'default' => 0), array('name' => 'id_member', 'type' => 'mediumint', 'unsigned' => true, 'size' => 10, 'default' => 0), array('name' => 'dismissed', 'type' => 'tinyint', 'size' => 10, 'default' => 0)), array(array('name' => 'dismissed_notices', 'type' => 'key', 'columns' => array('id_member', 'dismissed'))));
}
$context['installation_done'] = true;
}
示例2: resizeMessageTableBody
/**
* Resizes the body column from the messages table
*
* @package Maintenance
* @param string $type
*/
function resizeMessageTableBody($type)
{
$table = db_table();
$table->db_change_column('{db_prefix}messages', 'body', array('type' => $type));
}
示例3: db_delete
db_delete('organizations', $_GET['delete_id']);
url_drop('delete_id,action');
}
echo drawTop();
if (url_id()) {
//form
$f = new form('organizations', @$_GET['id']);
$f->set_field(array('type' => 'text', 'name' => 'title' . langExt(), 'label' => getString('title')));
langUnsetFields($f, 'title');
langTranslateCheckbox($f);
echo $f->draw();
} else {
//modules list
$t = new table('organizations', drawHeader());
$t->set_column('draggy', 'd', ' ');
$t->set_column('title', 'l', getString('title'));
$t->set_column('delete', 'd', ' ');
$result = db_table('SELECT id, title' . langExt() . ' title FROM organizations WHERE is_active = 1 ORDER BY precedence');
foreach ($result as &$r) {
$r['draggy'] = draw_img('/images/icons/move.png');
$r['title'] = draw_link('organizations.php?id=' . $r['id'], $r['title']);
$r['delete'] = drawColumnDelete($r['id']);
}
echo $t->draw($result, 'No organizations');
//add new
$f = new form('organizations');
$f->set_field(array('type' => 'text', 'name' => 'title' . langExt(), 'label' => getString('title')));
langUnsetFields($f, 'title');
echo $f->draw(false, false);
}
echo drawBottom();
示例4: getStruct
function getStruct($collection)
{
$table =& db_table($collection);
if ($table->getInfo()) {
return $table->columns;
}
$this->error = $table->error;
return false;
}
示例5: db_table
<?php
include "../../include.php";
if (url_id('module_id')) {
$result = db_table('SELECT p.id, p.title, p.url, p.is_hidden FROM pages p WHERE module_id = ' . $_GET['module_id'] . ' ORDER BY p.precedence');
} elseif (url_id('modulette_id')) {
$result = db_table('SELECT p.id, p.title, p.url, p.is_hidden FROM pages p WHERE modulette_id = ' . $_GET['modulette_id'] . ' ORDER BY p.precedence');
} else {
url_change('./');
}
echo drawTop();
//pages list
$t = new table('pages', drawHeader());
$t->set_column('is_hidden', 'd', ' ');
$t->set_column('draggy', 'd', ' ');
$t->set_column('title', 'l', getString('title'));
$t->set_column('url');
$t->set_draggable('draggy');
foreach ($result as &$r) {
$r['is_hidden'] = draw_form_checkbox('foo', !$r['is_hidden'], false, 'ajax_set(\'pages\', \'is_hidden\', ' . $r['id'] . ', ' . abs($r['is_hidden'] - 1) . ');');
$r['draggy'] = draw_img('/images/icons/move.png');
$r['title'] = draw_link('page.php?id=' . $r['id'], $r['title']);
if (empty($r['url'])) {
$r['url'] = 'index.php';
}
}
echo $t->draw($result, 'No pages');
echo drawBottom();
示例6: action_install2
//.........这里部分代码省略.........
$install_log = parsePackageInfo($packageInfo['xml'], false, 'uninstall');
// Gadzooks! There's no uninstaller at all!?
if (empty($install_log)) {
fatal_lang_error('package_uninstall_cannot', false);
}
// They can only uninstall from what it was originally installed into.
foreach ($theme_paths as $id => $data) {
if ($id != 1 && !in_array($id, $package_installed['old_themes'])) {
unset($theme_paths[$id]);
}
}
} elseif (isset($package_installed['old_version']) && $package_installed['old_version'] != $packageInfo['version']) {
// Look for an upgrade...
$install_log = parsePackageInfo($packageInfo['xml'], false, 'upgrade', $package_installed['old_version']);
// There was no upgrade....
if (empty($install_log)) {
$context['is_installed'] = true;
} else {
// Upgrade previous themes only!
foreach ($theme_paths as $id => $data) {
if ($id != 1 && !in_array($id, $package_installed['old_themes'])) {
unset($theme_paths[$id]);
}
}
}
} elseif (isset($package_installed['old_version']) && $package_installed['old_version'] == $packageInfo['version']) {
$context['is_installed'] = true;
}
if (!isset($package_installed['old_version']) || $context['is_installed']) {
$install_log = parsePackageInfo($packageInfo['xml'], false, 'install');
}
$context['install_finished'] = false;
// We're gonna be needing the table db functions! ...Sometimes.
$table_installer = db_table();
// @todo Make a log of any errors that occurred and output them?
if (!empty($install_log)) {
$failed_steps = array();
$failed_count = 0;
foreach ($install_log as $action) {
$failed_count++;
if ($action['type'] == 'modification' && !empty($action['filename'])) {
if ($action['boardmod']) {
$mod_actions = parseBoardMod(file_get_contents(BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename']), false, $action['reverse'], $theme_paths);
} else {
$mod_actions = parseModification(file_get_contents(BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename']), false, $action['reverse'], $theme_paths);
}
// Any errors worth noting?
foreach ($mod_actions as $key => $action) {
if ($action['type'] == 'failure') {
$failed_steps[] = array('file' => $action['filename'], 'large_step' => $failed_count, 'sub_step' => $key, 'theme' => 1);
}
// Gather the themes we installed into.
if (!empty($action['is_custom'])) {
$themes_installed[] = $action['is_custom'];
}
}
} elseif ($action['type'] == 'code' && !empty($action['filename'])) {
// This is just here as reference for what is available.
global $txt, $modSettings, $context;
// Now include the file and be done with it ;).
if (file_exists(BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename'])) {
require BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename'];
}
} elseif ($action['type'] == 'credits') {
// Time to build the billboard
$credits_tag = array('url' => $action['url'], 'license' => $action['license'], 'copyright' => $action['copyright'], 'title' => $action['title']);
示例7: array
FROM {db_prefix}membergroups
WHERE min_posts != {int:min_posts}', array('min_posts' => -1));
$post_groups = array();
while ($row = $db->fetch_assoc($request)) {
$post_groups[] = $row['id_group'];
}
$db->free_result($request);
$db->insert('replace', '{db_prefix}sp_profiles', array('id_profile' => 'int', 'type' => 'int', 'name' => 'text', 'value' => 'text'), array(array(1, 1, '$_guests', '-1|'), array(2, 1, '$_members', implode(',', $post_groups) . ',0|'), array(3, 1, '$_everyone', implode(',', $post_groups) . ',0,-1|')), array('id_profile'));
}
$db_package_log = array();
foreach ($sp_tables as $sp_table_name => $null) {
$db_package_log[] = array('remove_table', $db_prefix . $sp_table_name);
}
// Update the page table to accept more data
if (empty($modSettings['sp_version']) || $modSettings['sp_version'] < '2.4.1') {
$dbtbl = db_table();
$page_cols = $dbtbl->db_list_columns('{db_prefix}sp_pages', true);
if (isset($page_cols['body']) && $page_cols['body']['type'] == 'text') {
$dbtbl->db_change_column('{db_prefix}sp_pages', 'body', array('type' => 'mediumtext'));
}
}
// Update the block table to include the mobile column if needed
$request = $db->query('', 'SHOW FIELDS FROM {db_prefix}sp_blocks');
$fields = array();
while ($row = $db->fetch_assoc($request)) {
$fields[] = $row['Field'];
}
$db->free_result($request);
if (!in_array('mobile_view', $fields)) {
$db->query('', 'ALTER TABLE {db_prefix}sp_blocks ADD mobile_view TINYINT NOT NULL DEFAULT "0"');
}
示例8: header
<?php
global $cgi;
if (empty($cgi->_table)) {
header('Location: ' . site_prefix() . '/index/myadm-app');
exit;
}
$tbl = db_table($cgi->_table);
$data = $tbl->fetch($cgi->_key);
$trans = get_html_translation_table(HTML_ENTITIES);
foreach ($trans as $k => $v) {
$v = rawurlencode($v);
$v = preg_replace('/[^A-F0-9]+/', '', $v);
$v = '&#x' . $v . ';';
$trans[$k] = $v;
}
function xml_encode($data, $trans)
{
$data = str_replace(array_keys($trans), array_values($trans), $data);
return stripslashes($data);
}
header("content-type: application/x-octet-stream");
header("content-disposition: attachment; filename=" . $cgi->_table . '.' . $cgi->_key . '.xml');
echo '<?xml version="1.0"?' . '>' . NEWLINEx2;
echo '<table name="' . $cgi->_table . '">' . NEWLINE;
echo TAB . '<row>' . NEWLINE;
foreach (get_object_vars($data) as $key => $value) {
$value = xml_encode($value, $trans);
echo TABx2 . '<col name="' . $key . '">' . $value . '</col>' . NEWLINE;
}
echo TAB . '</row>' . NEWLINE;
示例9: drawSelectUser
<?php
$return .= '<tr><td colspan="2">' . drawSelectUser('staff', false, true, 0, true, true, "Jump to Staff Member") . '</td></tr>';
$pages = db_table('SELECT url, title' . langExt() . ' title FROM pages WHERE module_id = ' . $m['id'] . ' AND is_active = 1 AND is_hidden <> 1 AND is_admin <> 1 ORDER by precedence');
foreach ($pages as &$p) {
$p = draw_link('/staff/' . $p['url'], $p['title']);
}
$return .= draw_table_rows($pages);
示例10: langTranslatePost
<?php
include '../../include.php';
if ($posting) {
langTranslatePost('title');
$id = db_save('modulettes');
url_drop('id');
}
echo drawTop();
if (url_id()) {
//form
$f = new form('modulettes', @$_GET['id']);
langUnsetFields($f, 'title');
langTranslateCheckbox($f);
echo $f->draw();
} else {
//modulettes list
$t = new table('modulettes', drawHeader());
$t->set_column('is_active', 'd', ' ');
$t->set_column('title', 'l', getString('title'));
$t->set_column('pages', 'r');
$result = db_table('SELECT m.id, m.title' . langExt() . ' title, m.is_active, (SELECT COUNT(*) FROM pages p WHERE p.modulette_id = m.id) pages FROM modulettes m ORDER BY m.title' . langExt());
foreach ($result as &$r) {
$r['is_active'] = draw_form_checkbox('is_active', $r['is_active'], false, 'ajax_set(\'modulettes\', \'is_active\', ' . $r['id'] . ', ' . abs($r['is_active'] - 1) . ');');
$r['title'] = draw_link('modulettes.php?id=' . $r['id'], $r['title']);
$r['pages'] = draw_link('pages.php?modulette_id=' . $r['id'], format_quantitize($r['pages'], 'page'));
}
echo $t->draw($result, 'No modulettes');
}
echo drawBottom();
示例11: drawBBPosts
function drawBBPosts($count = 15, $error = '')
{
if ($topics = db_table("SELECT \n\t\t\tt.id,\n\t\t\tt.title,\n\t\t\tt.isAdmin,\n\t\t\tt.threadDate,\n\t\t\t(SELECT COUNT(*) FROM bulletin_board_followups f WHERE t.id = f.topicID AND f.isActive = 1) replies,\n\t\t\tISNULL(u.nickname, u.firstname) firstname,\n\t\t\tu.lastname\n\t\tFROM bulletin_board_topics t\n\t\tJOIN intranet_users u ON u.userID = t.createdBy\n\t\tWHERE t.isActive = 1 AND (t.temporary IS NULL OR t.temporary = 0 OR \n\t\t\t(t.temporary = 1 AND DATEDIFF(NOW(), t.createdOn) < 31))\n\t\tORDER BY t.threadDate DESC", $count)) {
foreach ($topics as &$topic) {
if ($topic["isAdmin"]) {
$topic["replies"] = "-";
}
$topic = '
<tr class="thread' . ($topic["isAdmin"] ? ' admin' : '') . '">
<td class="input"><a href="topic.php?id=' . $topic["id"] . '">' . $topic["title"] . '</a></td>
<td>' . $topic["firstname"] . ' ' . $topic["lastname"] . '</td>
<td align="center">' . $topic["replies"] . '</td>
<td align="right">' . format_date($topic["threadDate"]) . '</td>
</tr>';
}
return implode($topics);
} else {
return $error;
}
}
示例12: do_register
function do_register()
{
$network = get_network();
switch ($_GET['status']) {
case 'check':
$user_or_code = get_user();
if (!$user_or_code) {
$user_or_code = get_code();
}
if (!$user_or_code) {
echo 'available';
} else {
echo 'taken';
}
return;
case 'new_code':
$sql = 'INSERT INTO ' . db_table('codes') . ' (network_id, username, password, valid_from, created, ' . access_control_fields() . ') ' . 'VALUES (' . $network['id'] . ',\'' . $_GET['user'] . '\',\'' . $_GET['pass'] . '\', now(), now(), ' . access_control_values($network, 'defcode') . ')';
$resource = 'codes';
break;
case 'new_user':
$sql = 'INSERT INTO ' . db_table('users') . ' (network_id, username, password, valid_from, created, ' . access_control_fields() . ') ' . 'VALUES (' . $network['id'] . ',\'' . $_GET['user'] . '\',\'' . $_GET['pass'] . '\', now(), now(), ' . access_control_values($network, 'defuser') . ')';
$resource = 'users';
break;
}
db_query($sql, false);
$id = db_lastid();
if ($id) {
$input = $_POST;
if (!$input) {
$input = file_get_contents("php://input");
}
$lines = preg_split("/\n+/", $input);
$attrs = array();
foreach ($lines as $line) {
$p = preg_split('/[=: ]+/', $line, 2);
if ($p[0] && $p[1]) {
$attrs[$p[0]] = $p[1];
}
}
save_attributes($id, $resource, $attrs);
}
}
示例13: db_table
<?php
include '../include.php';
$result = db_table('SELECT
u.id link,
u.firstname,
u.lastname,
u.title,
d.departmentName department,
o.title organization,
u.email,
(SELECT CASE WHEN u.rankID = 9 THEN "No" ELSE "Yes" END) is_staff
FROM users u
LEFT JOIN departments d ON u.departmentID = d.departmentID
JOIN organizations o ON u.organization_id = o.id
WHERE u.is_active = 1
ORDER BY u.lastname, u.firstname');
foreach ($result as &$r) {
$r['link'] = draw_link(url_base() . '/staff/view.php?id=' . $r['link'], $r['link']);
}
file_array($result, 'employees');
示例14: drawTop
<?php
include "../include.php";
echo drawTop();
$result = db_table('SELECT
c.id,
c.title' . langExt() . ' title,
c.pub_date,
t.title' . langExt() . ' "group",
c.publication' . langExt() . ' publication,
' . db_updated('c') . '
FROM press_clips c
JOIN press_clips_types t ON c.type_id = t.id
' . getChannelsWhere('press_clips', 'c', 'clip_id') . '
ORDER BY t.title, pub_date DESC', 20);
$t = new table('press-clips', drawHeader(array('edit.php' => getString('add_new'))));
$t->set_column('title', 'l', getString('title'));
foreach ($result as &$r) {
$r['title'] = draw_link("clip.php?id=" . $r["id"], format_string($r["title"], 80)) . '<br>' . $r["publication"] . ' <span class="light">' . format_date($r["pub_date"]) . '</span>';
}
echo $t->draw($result, getString('pressclips_recent_empty'));
include "edit.php";
echo drawBottom();
示例15: protected_alter
/**
* This performs a table alter, but does it unbuffered so the script can time out professionally.
*
* @param string $change
* @param int $substep
* @param boolean $is_test
*/
function protected_alter($change, $substep, $is_test = false)
{
global $db_prefix;
$table = db_table();
$db = database();
// Firstly, check whether the current index/column exists.
$found = false;
if ($change['type'] === 'column') {
$columns = $table->db_list_columns('{db_prefix}' . $change['table'], true);
foreach ($columns as $column) {
// Found it?
if ($column['name'] === $change['name']) {
$found |= 1;
// Do some checks on the data if we have it set.
if (isset($change['col_type'])) {
$found &= $change['col_type'] === $column['type'];
}
if (isset($change['null_allowed'])) {
$found &= $column['null'] == $change['null_allowed'];
}
if (isset($change['default'])) {
$found &= $change['default'] === $column['default'];
}
}
}
} elseif ($change['type'] === 'index') {
$request = upgrade_query('
SHOW INDEX
FROM ' . $db_prefix . $change['table']);
if ($request !== false) {
$cur_index = array();
while ($row = $db->fetch_assoc($request)) {
if ($row['Key_name'] === $change['name']) {
$cur_index[(int) $row['Seq_in_index']] = $row['Column_name'];
}
}
ksort($cur_index, SORT_NUMERIC);
$found = array_values($cur_index) === $change['target_columns'];
$db->free_result($request);
}
}
// If we're trying to add and it's added, we're done.
if ($found && in_array($change['method'], array('add', 'change'))) {
return true;
} elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) {
return true;
} elseif ($is_test) {
return false;
}
// Not found it yet? Bummer! How about we see if we're currently doing it?
$running = false;
$found = false;
while (1 == 1) {
$request = upgrade_query('
SHOW FULL PROCESSLIST');
while ($row = $db->fetch_assoc($request)) {
if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) {
$found = true;
}
}
// Can't find it? Then we need to run it fools!
if (!$found && !$running) {
$db->free_result($request);
$success = upgrade_query('
ALTER TABLE ' . $db_prefix . $change['table'] . '
' . $change['text'], true) !== false;
if (!$success) {
return false;
}
// Return
$running = true;
} elseif (!$found) {
$db->free_result($request);
return true;
}
// Pause execution for a sec or three.
sleep(3);
// Can never be too well protected.
nextSubstep($substep);
}
// Protect it.
nextSubstep($substep);
}