本文整理汇总了PHP中SQL::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP SQL::fetch方法的具体用法?PHP SQL::fetch怎么用?PHP SQL::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQL
的用法示例。
在下文中一共展示了SQL::fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_init_language
function smarty_function_init_language($params, &$smarty)
{
global $site, $leht;
$content_template =& $leht->content_template;
##################
# default values
extract($params);
if (!isset($name)) {
$name = "language";
}
# / default values
###################
$sql = $site->db->prepare("SELECT keel_id AS id, nimi AS name, extension FROM keel WHERE on_kasutusel");
$sth = new SQL($sql);
$sth->debug->msg($sth->debug->get_msgs());
while ($result = $sth->fetch()) {
// if not in editor and use aliases has been enabled
if (!$site->in_editor && $site->CONF['use_aliases']) {
$result['href'] = $site->CONF['wwwroot'] . '/' . $result['extension'];
} else {
$result['href'] = $site->CONF['wwwroot'] . ($site->in_editor ? '/editor' : '') . '/?lang=' . $result['extension'];
}
$result['home_id'] = $site->alias(array('key' => 'rub_home_id', 'keel' => $result['id']));
$language[] = $result;
}
##############
# assign to template variables
$smarty->assign(array($name => $language));
}
示例2: layout
/**
* list comments
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// we return an array of ($url => $attributes)
$items = array();
// process all items in the list
include_once $context['path_to_root'] . 'comments/comments.php';
while ($item = SQL::fetch($result)) {
// url to view the comment
$url = Comments::get_url($item['id']);
// initialize variables
$prefix = $label = $suffix = $icon = '';
// the title as the label
if ($item['create_name']) {
$label .= ucfirst($item['create_name']) . ' ';
}
// time of creation
$label .= Skin::build_date($item['create_date']);
// text beginning
if ($text = Skin::strip($item['description'], 10, NULL, NULL)) {
$suffix = ' - ' . $text;
}
// list all components for this item
$items[$url] = array($prefix, $label, $suffix, 'comment', $icon);
}
// end of processing
SQL::free($result);
return $items;
}
示例3: layout
/**
* list sections
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// we return some text
$text = '';
// process all items in the list
while ($item = SQL::fetch($result)) {
// we want to make it visual
if (!$item['thumbnail_url']) {
continue;
}
// a title for the image --do not force a title
if (isset($item['title'])) {
$title = $item['title'];
} else {
$title = '';
}
// the url to view this item
$url = Sections::get_permalink($item);
// use the skin to shape it
$text .= Skin::build_image('thumbnail', $item['thumbnail_url'], $title, $url);
}
// end of processing
SQL::free($result);
return $text;
}
示例4: layout
/**
* list users
*
* @param resource the SQL result
* @return array of ($nick_name => $more)
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of ($nick_name => $more)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// process all items in the list
while ($item = SQL::fetch($result)) {
// unique identifier
$key = $item['nick_name'];
// use the full name, if nick name is not part of it
$more = '';
if ($item['full_name'] && !preg_match('/\\b' . preg_quote($item['nick_name'], '/') . '\\b/', $item['full_name'])) {
$more = ucfirst($item['full_name']) . ' ';
}
// else use e-mail address, if any --but only to authenticated surfer
if ($item['email'] && Surfer::is_logged()) {
if ($more) {
$more .= '<' . $item['email'] . '>';
} else {
$more .= $item['email'];
}
} elseif ($item['introduction']) {
$more .= $item['introduction'];
}
// record this item
$items[$key] = $more;
}
// end of processing
SQL::free($result);
return $items;
}
示例5: layout
/**
* list images
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// we return an array of ($url => $attributes)
$items = array();
// process all items in the list
while ($item = SQL::fetch($result)) {
// url to view the image
$url = Images::get_url($item['id']);
// initialize variables
$prefix = $suffix = '';
// flag new images
if ($item['edit_date'] >= $context['fresh']) {
$suffix .= NEW_FLAG;
}
// image title or image name
$label = Skin::strip($item['title'], 10);
if (!$label) {
$name_as_title = TRUE;
$label = ucfirst($item['image_name']);
}
$label = str_replace('_', ' ', str_replace('%20', ' ', $label));
// list all components for this item
$items[$url] = array($prefix, $label, $suffix, 'basic', NULL);
}
// end of processing
SQL::free($result);
return $items;
}
示例6: layout
/**
* list sections
*
* @param resource the SQL result
* @return an array of $url => (NULL, $title, NULL, 'section_123', NULL, 'visit this section')
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// no hovering label
$href_title = '';
// we return an array of ($url => $attributes)
$items = array();
// process all items in the list
while ($item = SQL::fetch($result)) {
// the url to view this item
$url = Sections::get_permalink($item);
// initialize variables
$prefix = $suffix = '';
// list all components for this item
$items[$url] = array($prefix, ucfirst(Skin::strip($item['index_title'], 30)), $suffix, 'section_' . $item['id'], NULL, $href_title);
}
// end of processing
SQL::free($result);
return $items;
}
示例7: layout
/**
* list links
*
* @param resource the SQL result
* @return array of resulting items, or NULL
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of ($url => $attributes)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// process all items in the list
while ($item = SQL::fetch($result)) {
// url is the link itself
$url = $item['link_url'];
// initialize variables
$prefix = $suffix = '';
// flag links that are dead, or created or updated very recently
if ($item['edit_date'] >= $context['fresh']) {
$suffix .= NEW_FLAG;
}
// make a label
$label = Links::clean($item['title'], $item['link_url'], 30);
// list all components for this item
$items[$url] = array($prefix, $label, $suffix, 'basic', NULL);
}
// end of processing
SQL::free($result);
return $items;
}
示例8: layout
/**
* list links
*
* @param resource the SQL result
* @return array of resulting items, or NULL
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of ($url => $attributes)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// process all items in the list
while ($item = SQL::fetch($result)) {
// get the main anchor
$anchor = Anchors::get($item['anchor']);
// url is the link itself -- hack for xhtml compliance
$url = str_replace('&', '&', $item['link_url']);
// initialize variables
$prefix = $suffix = '';
// flag links that are dead, or created or updated very recently
if ($item['edit_date'] >= $context['fresh']) {
$suffix = NEW_FLAG;
}
// make a label
$label = Links::clean($item['title'], $item['link_url']);
// the main anchor link
if (is_object($anchor)) {
$suffix .= ' - <span class="details">' . sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()))) . '</span>';
}
// list all components for this item
$items[$url] = array($prefix, $label, $suffix, 'basic', NULL);
}
// end of processing
SQL::free($result);
return $items;
}
示例9: layout
/**
* list users
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// we return an array of ($url => $attributes)
$items = array();
// process all items in the list
while ($item = SQL::fetch($result)) {
// we need some address
if (!$item['email']) {
continue;
}
// do not write to myself
// if($item['id'] == Surfer::get_id())
// continue;
$label = ucfirst(trim(Codes::beautify(strip_tags($item['full_name'], '<br><div><img><p><span>'))));
if (!$label) {
$label = ucfirst($item['nick_name']);
}
// one entry per address
$items[trim($item['email'])] = $label;
}
// end of processing
SQL::free($result);
return $items;
}
示例10: layout
/**
* list users
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return some text
$text = '';
// empty list
if (!($delta = SQL::count($result))) {
return $text;
}
// flag idle users
$idle = gmstrftime('%Y-%m-%d %H:%M:%S', time() - 600);
// process all items in the list
$count = 0;
$items = array();
while ($item = SQL::fetch($result)) {
// url to view the user
$url = Users::get_permalink($item);
// initialize variables
$prefix = $suffix = '';
// signal restricted and private users
if (isset($item['active']) && $item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif (isset($item['active']) && $item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// signal locked profiles
if (isset($item['capability']) && $item['capability'] == '?') {
$prefix .= EXPIRED_FLAG;
}
// item title
if (isset($item['full_name']) && $item['full_name']) {
$label = ucfirst(Skin::strip($item['full_name'], 10));
$hover = $item['nick_name'];
} else {
$label = ucfirst(Skin::strip($item['nick_name'], 10));
$hover = $item['full_name'];
}
// flag idle users
if (!isset($item['click_date']) || $item['click_date'] < $idle) {
$class = 'idle user';
} else {
$class = 'user';
}
// list all components for this item
$items[$url] = array($prefix, $label, $suffix, $class, NULL, $hover);
// provide only some results
if (++$count >= 5) {
break;
}
}
// end of processing
SQL::free($result);
// turn this to some text
$text = Skin::build_list($items, 'comma');
// some indications on the number of connections
if ($delta -= $count) {
$text .= ', ...';
}
return $text;
}
示例11: layout
/**
* list tables
*
* Recognize following variants:
* - 'no_anchor' to list items attached to one particular anchor
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of ($url => $attributes)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// process all items in the list
while ($item = SQL::fetch($result)) {
// initialize variables
$prefix = $suffix = $icon = '';
// the url to view this item
$url = Tables::get_url($item['id']);
// flag tables created or updated very recently
if ($item['create_date'] >= $context['fresh']) {
$suffix .= NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$suffix .= UPDATED_FLAG;
}
$label = Skin::strip($item['title'], 10);
// list all components for this item
$items[$url] = array($prefix, $label, $suffix, 'table', $icon);
}
// end of processing
SQL::free($result);
return $items;
}
示例12: layout
/**
* list versions
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// we return an array of ($url => $attributes)
$items = array();
// process all items in the list
while ($item = SQL::fetch($result)) {
// initialize variables
$prefix = $suffix = $icon = '';
// the url to view this item
$url = '_' . $item['id'];
// Versions::get_url($item['id']);
// version description
$label = sprintf(i18n::s('edited by %s %s'), ucfirst($item['edit_name']), Skin::build_date($item['edit_date']));
// command to view this version
$suffix .= ' ' . Skin::build_link(Versions::get_url($item['id'], 'view'), i18n::s('compare to current version'), 'button');
// list all components for this item
$items[$url] = array($prefix, $label, $suffix, 'version', $icon);
}
// end of processing
SQL::free($result);
return $items;
}
示例13: layout
/**
* list servers
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// we return an array of ($url => $attributes)
$items = array();
// process all items in the list
while ($item = SQL::fetch($result)) {
// initialize variables
$prefix = $suffix = $icon = '';
// the url to view this item
$url = Servers::get_url($item['id']);
// use the title as a label
$label = Skin::strip($item['title'], 10);
// list all components for this item
$items[$url] = array($prefix, $label, $suffix, 'server', $icon);
}
// end of processing
SQL::free($result);
return $items;
}
示例14: TreeSearch
function TreeSearch($searches, $classes, $language_id = 0)
{
global $site;
$this->classes = (array) $classes;
foreach ($this->classes as $i => $class) {
$this->classes[$i] = "'" . mysql_real_escape_string($class) . "'";
}
$sql = 'select tyyp_id from tyyp where klass in (' . implode(',', $this->classes) . ');';
$result = new SQL($sql);
$this->classes = array();
while ($row = $result->fetch('ASSOC')) {
$this->classes[] = $row['tyyp_id'];
}
$where = 'tyyp_id in (' . implode(',', $this->classes) . ') and keel = ' . mysql_real_escape_string($language_id) . ' ';
foreach ($searches as $field => $keyword) {
$where .= ' and ' . mysql_real_escape_string($field);
if ($field == 'objekt_id' || $field == 'ttyyp_id' || $field == 'page_tyyp_id' || $field == 'kesk') {
$where .= ' = ' . (int) $keyword;
} else {
$where .= " like '%" . mysql_real_escape_string($keyword) . "%' ";
}
}
$sql = 'select objekt_id from objekt where ' . $where . ';';
//printr($sql);
$result = new SQL($sql);
while ($row = $result->fetch('ASSOC')) {
$this->found_object_ids[] = $row['objekt_id'];
}
}
示例15: layout
/**
* list articles
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return some text
$text = '';
// empty list
if (!SQL::count($result)) {
return $text;
}
// clear flows
$text .= '<br style="clear: left" />';
// process all items in the list
while ($item = SQL::fetch($result)) {
// get the related overlay
$overlay = Overlay::load($item, 'article:' . $item['id']);
// the url to view this item
$url = Articles::get_permalink($item);
// use the title to label the link
if (is_object($overlay)) {
$title = Codes::beautify_title($overlay->get_text('title', $item));
} else {
$title = Codes::beautify_title($item['title']);
}
// the hovering title
if ($item['introduction'] && $context['skins_with_details'] == 'Y') {
$hover = strip_tags(Codes::beautify_introduction($item['introduction']));
} else {
$hover = i18n::s('View the page');
}
// title is a link to the target article
$title =& Skin::build_link($url, $title, 'basic', $hover);
// use the thumbnail for this article
if ($icon = trim($item['thumbnail_url'])) {
// fix relative path
if (!preg_match('/^(\\/|http:|https:|ftp:)/', $icon)) {
$icon = $context['url_to_root'] . $icon;
}
// use parameter of the control panel for this one
$options = '';
if (isset($context['classes_for_thumbnail_images'])) {
$options = 'class="' . $context['classes_for_thumbnail_images'] . '" ';
}
// build the complete HTML element
$icon = '<img src="' . $icon . '" alt="" title="' . encode_field($hover) . '" ' . $options . ' />';
// use default icon if nothing to display
} else {
$icon = MAP_IMG;
}
// use the image as a link to the target page
$icon =& Skin::build_link($url, $icon, 'basic', $hover);
// add a floating box
$text .= Skin::build_box($title, $icon, 'floating');
}
// clear flows
$text .= '<br style="clear: left" />';
// end of processing
SQL::free($result);
return $text;
}