本文整理汇总了PHP中SQL::table_name方法的典型用法代码示例。如果您正苦于以下问题:PHP SQL::table_name方法的具体用法?PHP SQL::table_name怎么用?PHP SQL::table_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQL
的用法示例。
在下文中一共展示了SQL::table_name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cascade
/**
* cascade to children
*
* @param string referencing of the changed anchor
* @param string rights to be cascaded (e.g., 'Y', 'R' or 'N')
*/
public static function cascade($reference, $active)
{
global $context;
// only sections may have sub-sections
if (strpos($reference, 'section:') === 0) {
// cascade to sub-sections
if ($items = Sections::list_for_anchor($reference, 'raw')) {
// cascade to each section individually
foreach ($items as $id => $item) {
// limit actual rights
$item['active'] = Anchors::ceil_rights($active, $item['active_set']);
$query = "UPDATE " . SQL::table_name('sections') . " SET active='" . SQL::escape($item['active']) . "' WHERE id = " . SQL::escape($id);
SQL::query($query);
// cascade to children
Anchors::cascade('section:' . $item['id'], $item['active']);
}
}
}
// only categories may have sub-categories
if (strpos($reference, 'category:') === 0) {
// cascade to sub-categories
if ($items = Categories::list_for_anchor($reference, 'raw')) {
// cascade to each section individually
foreach ($items as $id => $item) {
// limit actual rights
$item['active'] = Anchors::ceil_rights($active, $item['active_set']);
$query = "UPDATE " . SQL::table_name('categories') . " SET active='" . SQL::escape($item['active']) . "' WHERE id = " . SQL::escape($id);
SQL::query($query);
// cascade to children
Anchors::cascade('category:' . $item['id'], $item['active']);
}
}
}
// only sections may have articles
if (strpos($reference, 'section:') === 0) {
// cascade to articles --up to 3000
if ($items =& Articles::list_for_anchor_by('edition', $reference, 0, 3000, 'raw')) {
// cascade to each section individually
foreach ($items as $id => $item) {
// limit actual rights
$item['active'] = Anchors::ceil_rights($active, $item['active_set']);
$query = "UPDATE " . SQL::table_name('articles') . " SET active='" . SQL::escape($item['active']) . "' WHERE id = " . SQL::escape($id);
SQL::query($query);
// cascade to children
Anchors::cascade('article:' . $item['id'], $item['active']);
}
}
}
// cascade to files --up to 3000
if ($items = Files::list_by_date_for_anchor($reference, 0, 3000, 'raw')) {
// cascade to each section individually
foreach ($items as $id => $item) {
// limit actual rights
$item['active'] = Anchors::ceil_rights($active, $item['active_set']);
$query = "UPDATE " . SQL::table_name('files') . " SET active='" . SQL::escape($item['active']) . "' WHERE id = " . SQL::escape($id);
SQL::query($query);
}
}
}
示例2: confirm
/**
* remember that surfer is enrolled in a meeting
*
* @param string reference of the target page
*/
public static function confirm($reference)
{
global $context;
// sanity check
if (!$reference) {
return;
}
// ensure that the joiner has been enrolled...
if (!($item = enrolments::get_record($reference))) {
if (Surfer::get_id()) {
// fields to save
$query = array();
$query[] = "anchor = '" . $reference . "'";
$query[] = "approved = 'Y'";
$query[] = "edit_date = '" . SQL::escape(gmstrftime('%Y-%m-%d %H:%M:%S')) . "'";
$query[] = "user_id = " . SQL::escape(Surfer::get_id());
$query[] = "user_email = '" . SQL::escape(Surfer::get_email_address()) . "'";
// insert a new record
$query = "INSERT INTO " . SQL::table_name('enrolments') . " SET " . implode(', ', $query);
SQL::query($query);
}
// each joiner takes one seat
} else {
$query = "UPDATE " . SQL::table_name('enrolments') . " SET approved = 'Y' WHERE id = " . SQL::escape($item['id']);
SQL::query($query);
}
}
示例3: stat_for_anchor
/**
* get some statistics for one anchor
*
* @param the selected anchor (e.g., 'article:12')
* @return the resulting ($count, $min_date, $max_date) array
*
* @see articles/delete.php
* @see articles/view.php
* @see categories/delete.php
* @see categories/view.php
* @see sections/delete.php
* @see sections/sections.php
* @see sections/view.php
* @see skins/layout_home_articles_as_alistapart.php
* @see skins/layout_home_articles_as_hardboiled.php
* @see skins/layout_home_articles_as_daily.php
* @see skins/layout_home_articles_as_newspaper.php
* @see skins/layout_home_articles_as_slashdot.php
* @see skins/skin_skeleton.php
* @see users/delete.php
*/
public static function stat_for_anchor($anchor)
{
global $context;
// select among available items
$query = "SELECT COUNT(*) as count, MIN(edit_date) as oldest_date, MAX(edit_date) as newest_date" . " FROM " . SQL::table_name('links') . " AS links" . " WHERE links.anchor LIKE '" . SQL::escape($anchor) . "'";
$output = SQL::query_first($query);
return $output;
}
示例4: transcode
/**
* transcode some references
*
* @param array of pairs of strings to be used in preg_replace()
*
* @see images/images.php
*/
function transcode($transcoded)
{
global $context;
// no item bound
if (!isset($this->item['id'])) {
return;
}
// prepare preg_replace()
$from = array();
$to = array();
foreach ($transcoded as $pair) {
$from[] = $pair[0];
$to[] = $pair[1];
}
// transcode various fields
$this->item['introduction'] = preg_replace($from, $to, $this->item['introduction']);
$this->item['description'] = preg_replace($from, $to, $this->item['description']);
// update the database
$query = "UPDATE " . SQL::table_name('categories') . " SET " . " introduction = '" . SQL::escape($this->item['introduction']) . "'," . " description = '" . SQL::escape($this->item['description']) . "'" . " WHERE id = " . SQL::escape($this->item['id']);
SQL::query($query);
// always clear the cache, even on no update
Categories::clear($this->item);
}
示例5: load_skin
*/
// include global declarations
include_once '../shared/global.php';
// load localized strings
i18n::bind('scripts');
// load the skin
load_skin('scripts');
// the path to this page
$context['path_bar'] = array('control/' => i18n::s('Control Panel'));
// the title of the page
$context['page_title'] = i18n::s('Run one-time scripts');
// the list of script to take into account
global $scripts;
$scripts = array();
// if the user table exists, check that the user is an admin
$query = "SELECT count(*) FROM " . SQL::table_name('users');
if (SQL::query($query) !== FALSE && !Surfer::is_associate()) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// open the directory
} elseif (!($dir = Safe::opendir($context['path_to_root'] . 'scripts/run_once'))) {
Logger::error(sprintf(i18n::s('Impossible to read %s.'), $context['path_to_run_once_scripts']));
} else {
while (($item = Safe::readdir($dir)) !== FALSE) {
// script name has to start with a number --actually, a date
if ($item[0] < '0' || $item[0] > '9') {
continue;
}
// we only consider php scripts, of course
if (strlen($item) < 5 || substr($item, -4) != '.php') {
continue;
示例6: stat
/**
* get some statistics
*
* @return the resulting ($count, $min_date, $max_date) array
*/
public static function stat()
{
global $context;
// select among active and restricted items
$where = "servers.active='Y'";
if (Surfer::is_member()) {
$where .= " OR servers.active='R'";
}
if (Surfer::is_associate()) {
$where .= " OR servers.active='N'";
}
// select among available items
$query = "SELECT COUNT(*) as count, MIN(edit_date) as oldest_date, MAX(edit_date) as newest_date" . ' FROM ' . SQL::table_name('servers') . ' AS servers' . ' WHERE (' . $where . ')';
$output = SQL::query_first($query);
return $output;
}
示例7: sprintf
}
// ending message
$context['text'] .= sprintf(i18n::s('%d records have been processed'), $count) . BR . "\n";
// display the execution time
$time = round(get_micro_time() - $context['start_time'], 2);
$context['text'] .= '<p>' . sprintf(i18n::s('Script terminated in %.2f seconds.'), $time) . '</p>';
// forward to the index page
$menu = array('sections/' => i18n::s('Site map'));
$context['text'] .= Skin::build_list($menu, 'menu_bar');
// look for orphans
} elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'orphans') {
// scan sections
$context['text'] .= Skin::build_block(sprintf(i18n::s('Analyzing table %s...'), SQL::table_name('sections')), 'title');
// scan up to 10000 sections
$count = 0;
$query = "SELECT id, anchor, title FROM " . SQL::table_name('sections') . " ORDER BY anchor LIMIT 0, 10000";
// parse the whole list
if ($result = SQL::query($query)) {
// retrieve the id and a printable label
$errors_count = 0;
while ($row = SQL::fetch($result)) {
// animate user screen and take care of time
$count++;
if (!($count % 100)) {
$context['text'] .= sprintf(i18n::s('%d records have been processed'), $count) . BR . "\n";
// ensure enough execution time
Safe::set_time_limit(30);
}
// check that the anchor exists, if any
if ($row['anchor'] && !Anchors::get($row['anchor'])) {
$context['text'] .= sprintf(i18n::s('Orphan: %s'), 'section ' . Skin::build_link(Sections::get_permalink($row), $row['id'] . ' ' . $row['title'], 'section')) . BR . "\n";
示例8: elseif
$text .= Logger::error_pop() . BR . "\n";
}
}
// tables
//
$text .= Skin::build_block(i18n::s('Tables'), 'subtitle');
// 'my_articles' article
if (Tables::get('my_articles')) {
$text .= i18n::s('A sample "my_articles" table already exists.') . BR . "\n";
} elseif ($anchor = Articles::lookup('my_article')) {
$fields = array();
$fields['anchor'] = $anchor;
$fields['nick_name'] = 'my_articles';
$fields['title'] = i18n::c('My Articles');
$fields['description'] = i18n::c('This is a sample table to let you learn and practice.');
$fields['query'] = "SELECT \n" . "articles.title as titre, \n" . "articles.id as 'id', \n" . "articles.introduction as introduction, \n" . "articles.edit_name as 'last editor', \n" . "articles.edit_date as 'Date' \n" . "FROM " . SQL::table_name('articles') . " AS articles \n" . "WHERE (articles.active='Y') \n" . "ORDER BY articles.rank, articles.edit_date DESC, articles.title LIMIT 0,10";
if (Tables::post($fields)) {
$text .= sprintf(i18n::s('A table "%s" has been created.'), $fields['nick_name']) . BR . "\n";
} else {
$text .= Logger::error_pop() . BR . "\n";
}
}
// job done
$context['text'] .= $text;
// follow-up commands
$menu = array();
$menu = array_merge($menu, array('sections/' => i18n::s('Check the updated Site Map')));
$menu = array_merge($menu, array('help/populate.php' => i18n::s('Launch the Content Assistant again')));
$menu = array_merge($menu, array('control/' => i18n::s('Control Panel')));
$context['text'] .= Skin::build_box(i18n::s('What do you want to do now?'), Skin::build_list($menu, 'menu_bar'), 'page_bottom');
// flush the cache
示例9: should_notify_watchers
/**
* notify watchers or not?
*
* This function is used in various scripts to customize notification of watchers.
*
* @see articles/edit.php
* @see articles/publish.php
*
* @param array if provided, a notification that can be sent to customised recipients
* @return boolean always FALSE for events, since notifications are made through enrolment
*/
function should_notify_watchers($mail = NULL)
{
global $context;
// sent notification to all enrolled persons
if ($mail) {
// list enrolment for this meeting
$query = "SELECT user_id FROM " . SQL::table_name('enrolments') . " WHERE anchor LIKE '" . SQL::escape($this->anchor->get_reference()) . "'";
if ($result = SQL::query($query)) {
// browse the list
while ($item = SQL::fetch($result)) {
// a user registered on this server
if ($item['user_id'] && ($watcher = Users::get($item['user_id']))) {
// skip banned users
if ($watcher['capability'] == '?') {
continue;
}
// skip current surfer
if (Surfer::get_id() && Surfer::get_id() == $item['user_id']) {
continue;
}
// ensure this surfer wants to be alerted
if ($watcher['without_alerts'] != 'Y') {
Users::alert($watcher, $mail);
}
}
}
}
}
// prevent normal cascading of notifications
return FALSE;
}
示例10: stat_threads
/**
* get some statistics on threads
*
* @return the resulting ($count, $min_date, $max_date) array
*
* @see comments/index.php
*/
public static function stat_threads()
{
global $context;
// a dynamic where clause
$where = '';
// if not associate, restrict to comments at public published not expired pages
if (!Surfer::is_associate()) {
$where = "(articles.active='Y')" . " AND NOT ((articles.publish_date is NULL) OR (articles.publish_date <= '0000-00-00'))" . " AND ((articles.expiry_date is NULL)" . "\tOR (articles.expiry_date <= '" . NULL_DATE . "') OR (articles.expiry_date > '" . gmstrftime('%Y-%m-%d %H:%M:%S') . "'))";
}
// avoid blank records on join
if ($where) {
$where .= ' AND ';
}
$where .= '(articles.id > 0)';
// the list of comments
$query = "SELECT DISTINCT articles.id as id FROM " . SQL::table_name('comments') . " AS comments" . ", " . SQL::table_name('articles') . " AS articles" . " WHERE (comments.anchor_type LIKE 'article') AND (comments.anchor_id = articles.id)" . "\tAND " . $where;
// select among available items
$result = SQL::query($query);
$output = SQL::count($result);
return $output;
}
示例11: REPLACE
$text .= Skin::build_block(i18n::s('Analysing icons for categories'), 'title');
// query to update
$query = "UPDATE " . SQL::table_name('categories') . " SET ";
$query .= "icon_url= REPLACE(icon_url,'" . $former_url . "','" . $context['url_to_root'] . "images/')";
// proceed
$result = SQL::query($query);
// nb of lines
if ($result) {
$text .= '<p>' . $result . ' line(s) updated</p>';
} else {
$text .= '<p>No line updated</p>';
}
// VII ANALYSE THUMBNAILS IN FILES TABLE
$text .= Skin::build_block(i18n::s('Analysing thumbnails for files'), 'title');
// query to update
$query = "UPDATE " . SQL::table_name('files') . " SET ";
$query .= "thumbnail_url= REPLACE(thumbnail_url,'" . $former_url . "','" . $context['url_to_root'] . "images/')";
// proceed
$result = SQL::query($query);
// nb of lines
if ($result) {
$text .= '<p>' . $result . ' line(s) updated</p>';
} else {
$text .= '<p>No line updated</p>';
}
// END : report
$context['text'] = $text;
}
} else {
$context['text'] = '<p>' . i18n::s('This tools correct the urls of thumbnails and icons of pages after having changed "url_to_root" in control panel') . '</p>';
// the form to get the former URL to root and start the process
示例12: stat_for_anchor
/**
* get some statistics for one anchor
*
* @param the selected anchor (e.g., 'article:12')
* @return the resulting ($count, $oldest_date, $newest_date, $total_size) array
*/
public static function stat_for_anchor($anchor)
{
global $context;
// sanity check
if (!$anchor) {
return NULL;
}
// limit the scope of the request
$where = Files::get_sql_where();
// select among available items
$query = "SELECT COUNT(*) as count, MIN(edit_date) as oldest_date, MAX(edit_date) as newest_date" . ", SUM(file_size) as total_size" . " FROM " . SQL::table_name('files') . " AS files" . " WHERE files.anchor LIKE '" . SQL::escape($anchor) . "' AND " . $where;
$output = SQL::query_first($query);
return $output;
}
示例13: unpublish
/**
* unpublish an article
*
* Clear all publishing information
*
* @param int the id of the item to unpublish
* @return string either a null string, or some text describing an error to be inserted into the html response
* @see articles/unpublish.php
**/
public static function unpublish($id)
{
global $context;
// id cannot be empty
if (!$id || !is_numeric($id)) {
return i18n::s('No item has the provided id.');
}
// set default values
$fields = array();
Surfer::check_default_editor($fields);
// update an existing record, except the date
$query = "UPDATE " . SQL::table_name('articles') . " SET " . " publish_name=''," . " publish_id=0," . " publish_address=''," . " publish_date=''," . " edit_name='" . SQL::escape($fields['edit_name']) . "'," . " edit_id=" . SQL::escape($fields['edit_id']) . "," . " edit_address='" . SQL::escape($fields['edit_address']) . "'," . " edit_action='article:update'" . " WHERE id = " . SQL::escape($id);
SQL::query($query);
// end of job
return NULL;
}
示例14: stat
/**
* get some statistics
*
* @return the number of rows in table
*
* @see control/index.php
*/
public static function stat()
{
global $context;
// select among available items
$query = "SELECT COUNT(*) as count FROM " . SQL::table_name('profiles');
$output = SQL::query_first($query);
return $output;
}
示例15: sprintf
$query = "UPDATE " . SQL::table_name('sections') . " SET owner_id = " . $user['id'] . " WHERE owner_id = " . $item['id'];
if ($count = SQL::query($query)) {
$context['text'] .= BR . sprintf(i18n::s('%d sections have been updated'), $count);
}
// change all pages at once
$query = "UPDATE " . SQL::table_name('articles') . " SET owner_id = " . $user['id'] . " WHERE owner_id = " . $item['id'];
if ($count = SQL::query($query)) {
$context['text'] .= BR . sprintf(i18n::s('%d articles have been updated'), $count);
}
// change editor records
$query = "UPDATE " . SQL::table_name('members') . " SET anchor = 'user:" . $user['id'] . "' WHERE anchor LIKE 'user:" . $item['id'] . "'";
if ($count = SQL::query($query)) {
$context['text'] .= BR . sprintf(i18n::s('%d editor assignments have been updated'), $count);
}
// change watch lists
$query = "UPDATE " . SQL::table_name('members') . " SET member = 'user:" . $user['id'] . "'" . ", member_type = 'user', member_id = " . $user['id'] . " WHERE member LIKE 'user:" . $item['id'] . "'";
if ($count = SQL::query($query)) {
$context['text'] .= BR . sprintf(i18n::s('%d watching assignments have been updated'), $count);
}
// back to the anchor page
$links = array();
$links[] = Skin::build_link(Users::get_permalink($item), i18n::s('Done'), 'button');
$context['text'] .= Skin::finalize_list($links, 'assistant_bar');
// ask for the new owner
} else {
// delegate to another person
$context['text'] .= '<p style="margin-top: 2em;">' . i18n::s('To transfer ownership to another person, type some letters of the name you are looking for.') . '</p>';
// the form to link additional users
$context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><p>' . '<input type="text" name="assigned_name" id="name" size="45" maxlength="255" />' . '<input type="hidden" name="id" value="' . encode_field($item['id']) . '">' . '<input type="hidden" name="action" value="set">' . '</p></form>' . "\n";
// enable autocompletion
Page::insert_script('$(function() {' . "\n" . ' $("#name").focus();' . "\n" . ' Yacs.autocomplete_names("name",true);' . "\n" . '});' . "\n");