本文整理汇总了PHP中dbAll函数的典型用法代码示例。如果您正苦于以下问题:PHP dbAll函数的具体用法?PHP dbAll怎么用?PHP dbAll使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbAll函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Meetings_formsGet
/**
* get a form
*
* @return array
*/
function Meetings_formsGet()
{
if (!isset($_SESSION['userdata'])) {
return false;
}
return dbAll('select * from forms_nonpage');
}
示例2: Ads_widget
/**
* show ads
*
* @param array $params parameters
*
* @return ads HTML
*/
function Ads_widget($params)
{
if (!isset($params->{'ad-type'})) {
return 'missing ad type';
}
$type_id = (int) $params->{'ad-type'};
$howmany = (int) $params->{'how-many'};
$type = dbRow('select * from ads_types where id=' . $type_id);
$ads = array();
$i = 0;
if ($howmany > 1) {
$sql = 'select id,image_url,target_type,poster from ads' . ' where type_id=' . $type_id . ' and is_active and cdate>date_add(now(), interval -2 day) order by rand()' . ' limit ' . $howmany;
$adsNew = dbAll($sql);
for (; $i < count($adsNew); ++$i) {
$ads[] = $adsNew[$i];
}
}
$adsOld = dbAll('select id,image_url,target_type,poster from ads' . ' where type_id=' . $type_id . ' and is_active order by rand()' . ' limit ' . $howmany);
for ($j = 0; $j < $howmany - $i && $j < count($adsOld); ++$j) {
$ads[] = $adsOld[$j];
}
$html = '<div class="ads-wrapper type-' . $type_id . '">';
foreach ($ads as $ad) {
$html .= Ads_adShow($ad, $type);
dbQuery('insert into ads_track set ad_id=' . $ad['id'] . ', view=1, cdate=now()');
}
$html .= '</div>';
WW_addScript('ads/j/js.js');
WW_addCSS('/ww.plugins/ads/css.css');
return $html;
}
示例3: send_email
function send_email($subject, $body, $type, $reply_to)
{
if ($subject == '' || $body == '') {
return false;
}
$options = dbAll('select name,value from mailing_list_options');
foreach ($options as $option) {
$OPT[$option['name']] = $option['value'];
}
$list = dbAll('select * from mailing_list where status="activated"');
$emails = '';
$num = '';
foreach ($list as $email) {
$emails .= $email['email'] . ',';
$num++;
}
$headers = 'From: ' . $OPT['email'] . "\r\n";
if ($repyl_to != '') {
$headers .= 'Reply-To:' . $reply_to . "\r\n";
}
if ($type == 'HTML') {
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
} else {
$headers .= 'Content-Type: text/plain; charset=iso-8859-1' . "\r\n";
}
if ($OPT['use_bcc'] == 1) {
$headers .= 'Bcc: ' . $emails . "\r\n";
} else {
$to = $emails;
}
$headers .= 'X-Mailer: PHP ' . phpversion();
$headers .= 'MIME-Version: 1.0' . "\n";
mail($to, $subject, $body, $headers);
return $num;
}
示例4: BannerImage_drawForm
/**
* blah
*
* @param int $id id of the banner
*
* @return null
*/
function BannerImage_drawForm($id = 0)
{
if (!$id) {
$fdata = array('id' => 0, 'html' => '', 'name' => 'banner');
} else {
$fdata = dbRow("select * from banners_images where id={$id}");
}
echo '<form method="post" action="/ww.admin/plugin.php?_plugin=banner-ima' . 'ge&_page=index" enctype="multipart/form-data"><input type="hidden' . '" name="id" value="' . (int) $fdata['id'] . '" />';
echo '<table>';
// {
echo '<tr><th>Name</th><td><input name="name" value="' . htmlspecialchars($fdata['name']) . '" /></td></tr>';
// }
// { what pages should this be applied to
echo '<tr><th>Pages</th><td>This banner will only be shown on the <select' . ' name="pages_' . $fdata['id'] . '[]" multiple="multiple" style="max-width' . ':200px;height:500px">';
$ps = dbAll('select * from banners_pages where bannerid=' . $fdata['id']);
$pages = array();
if (count($ps)) {
foreach ($ps as $p) {
$pages[] = $p['pageid'];
}
}
BannerImage_selectKiddies(0, 1, $pages);
echo '</select> pages. <span style="color:red;font-weight:bold">If no pag' . 'es are specified, then the banner will be shown on all pages.</span><' . '/td></tr>';
// }
// { show HTML form
echo '<tr><th>Banner</th><td><div id="banner_image_html">' . ckeditor('html_' . $fdata['id'], Core_unfixImageResizes($fdata['html']), 0, '', 180) . '</div></td></tr>';
// }
// { show submit button and end form
echo '<tr><td><a href="./plugin.php?_plugin=banner-image&_page=index&dele' . 'te_banner=' . $fdata['id'] . '" onclick="return confirm(\'are you sure yo' . 'u want to remove this banner?\');" title="remove banner">[x]</a></td>' . '<td><input type="submit" name="save_banner" value="Update" /></td></tr>';
// }
echo '</table></form>';
}
示例5: Ads_typesGet
/**
* get all ad types
*
* @return list of ad types
*/
function Ads_typesGet()
{
$sql = 'select * from ads_types';
if (isset($_REQUEST['not_for_sale'])) {
$sql .= ' where not_for_sale=' . (int) $_REQUEST['not_for_sale'];
}
return dbAll($sql . ' order by name');
}
示例6: Comments_getListOfComments
/**
* retrieve a list of comments for the page
*
* @param object $page Page object
* @param string $dir sort ascending or descending by date
* @param int $num how many comments to get - 0=all
* @param array $also array of comment ids to show whether valid or not
*
* @return array list of comments
**/
function Comments_getListOfComments($page, $dir = '', $num = 0, $also = array())
{
$query = 'select * from comments where objectid=' . $page->id . ' and (isvalid=1';
if (count($also)) {
$query .= ' or id in (' . join(',', $also) . ')';
}
$limit = $num ? ' limit 0,' . $num : '';
return dbAll($query . ') order by cdate ' . $dir . $limit);
}
示例7: DynamicSearch_catags
/**
* DynamicSearch_catags
*
* @param array $catags categories
* @param string $s search string
* @param string $cat category to search
* @param int $limit how many results to return
*
* @return array
*/
function DynamicSearch_catags($catags, $s, $cat, $limit)
{
if (!in_array($cat, $catags)) {
die('Category does not exist.');
}
$id = dbOne('select id from pages where name="' . $cat . '"', 'id');
$gd = getDescendants($id);
$q = dbAll('select * from pages where (id=' . $id . ' ' . $gd . ') and (body like "%' . $s . '%" or name like "%' . $s . '%") order by edate limit ' . $limit);
return $q;
}
示例8: show_banner
function show_banner($vars)
{
$banner = false;
if (!is_array($vars) && @$vars->id) {
$b = Core_cacheLoad('banner-images', 'id' . $vars->id);
if ($b === false) {
$b = dbRow('select * from banners_images where id=' . $vars->id);
if ($b && count($b) && !$b['html']) {
$b['html'] = BannerImage_getImgHtml($vars->id);
dbQuery('update banners_pages set html="' . addslashes($b['html']) . '" where id=' . $vars->id);
}
Core_cacheSave('banner-images', 'id' . $vars->id, $b);
}
} elseif ($GLOBALS['PAGEDATA']->id) {
$b = Core_cacheLoad('banner-images', 'bypage' . $GLOBALS['PAGEDATA']->id);
if ($b === false) {
$b = dbAll('select * from banners_pages,banners_images where pageid=' . $GLOBALS['PAGEDATA']->id . ' and bannerid=id');
Core_cacheSave('banner-images', 'bypage' . $GLOBALS['PAGEDATA']->id, $b);
}
$i = rand(0, count($b) - 1);
$b = isset($b[$i]) ? $b[$i] : false;
if ($b && count($b) && !$b['html']) {
$b['html'] = BannerImage_getImgHtml($b['id']);
dbQuery('update banners_pages set html="' . addslashes($b['html']) . '" where id=' . $b['id']);
}
}
if (!isset($b) || $b === false || !count($b)) {
$b = Core_cacheLoad('banner-image', 'all');
if ($b === false) {
$b = dbAll('select * from banners_images');
Core_cacheSave('banner-image', 'all', $b);
}
$i = rand(0, count($b) - 1);
$b = isset($b[$i]) ? $b[$i] : false;
}
if ($b && count($b)) {
$banner = $b['html'];
if (!$banner) {
$banner = BannerImage_getImgHtml($vars->id);
}
}
if (!$banner) {
if (is_array($vars) && @$vars['default']) {
$banner = $vars['default'];
} else {
$banner = '';
}
}
if (!$banner) {
return '';
}
return '<style type="text/css">#banner{background:none}</style>' . $banner;
}
示例9: Search_showResults
/**
* retrieve list of search results
*
* @return string HTML list of search results
*/
function Search_showResults()
{
global $PLUGINS;
// { variables
global $PAGEDATA;
$start = (int) @$_REQUEST['start'];
$search = @$_REQUEST['search'];
if (!$search) {
return '<em id="searchResultsTitle">no search text entered</em>';
}
$c = '';
// }
// { pages
$q = dbAll('select * from pages where (name like "%' . $search . '%" or body like "%' . $search . '%") order by edate desc limit ' . $start . ',20');
$n = count($q);
if ($n > 0) {
foreach ($q as $p) {
Page::getInstance($p['id'], $p);
}
$q = array_slice($q, $start, 20);
$c .= '<h2>Page Search Results</h2><em id="searchResultsTitle">';
if ($n == 1) {
$c .= '1 result found';
} else {
$c .= $n . ' results found';
}
$c .= '</em> <div>';
if ($start > 0) {
$c .= '[<a href="' . $PAGEDATA->getRelativeURL() . '?search=' . urlencode($search) . '&start=' . ($start - 20) . '">previous 20</a>] ';
}
if ($start + 20 < $n) {
$c .= '[<a href="' . $PAGEDATA->getRelativeURL() . '?search=' . urlencode($search) . '&start=' . ($start + 20) . '">next 20</a>] ';
}
$c .= '<ol start="' . ($start + 1) . '" id="searchResults">';
foreach ($q as $r) {
$title = $r['title'] == '' ? $r['name'] : $r['title'];
$c .= '<li><h4>' . htmlspecialchars($title) . '</h4>' . '<p>' . substr(preg_replace('/<[^>]*>/', '', $r['body']), 0, 200) . '...<br /><a href="/' . urlencode($r['name']) . '?search=' . $search . '">/' . htmlspecialchars($r['name']) . '</a></p></li>';
}
$c .= '</ol></div>';
}
// }
// { others
foreach ($PLUGINS as $plugin) {
if (@$plugin['search']) {
$c .= $plugin['search']();
}
}
// }
if (!$c) {
return '<em id="searchResultsTitle">' . __('no results found', 'core') . '</em>';
}
return $c;
}
示例10: getByIds
static function getByIds($ids = array())
{
$ids = addslashes(join(',', $ids));
if (array_key_exists($ids, self::$instancesByIds)) {
return self::$instancesByIds[$ids];
}
self::$instancesByFilter[$ids] = array();
$rs = dbAll("select * from poll where id in ({$ids})");
foreach ($rs as $r) {
self::$instancesByIds[$ids][] = Poll::getInstance($r['id'], $r);
}
return self::$instancesByIds[$ids];
}
示例11: getGroups
function getGroups()
{
if (isset($this->groups)) {
return $this->groups;
}
$byid = array();
$gs = dbAll('select groups_id from users_groups ' . 'where user_accounts_id=' . $this->id);
foreach ($gs as $g) {
$byid[] = $g['groups_id'];
}
$this->groups = $byid;
return $this->groups;
}
示例12: __construct
/**
* get list of pages that have a common parent
*
* @param string $constraint the SQL constraint to use
* @param boolean $filter whether to only show "published" pages
*
* @return object the Pages object
*/
function __construct($constraint, $filter = true)
{
global $isadmin;
$filter = $isadmin || !$filter ? '' : ' && !(special&2)';
$rs = dbAll("select * from pages where {$constraint} {$filter} " . "order by special&2,ord,name");
if (!count($rs)) {
$rs = array();
}
foreach ($rs as $r) {
$this->pages[] = Page::getInstance($r['id'], $r);
}
Pages::$instancesByParent[$constraint] =& $this;
}
示例13: OnlineStore_voucherCheckValidity
/**
* check if a voucher is valid
*
* @param string $code the voucher to check
* @param string $email the user's email address
*
* @return boolean
*/
function OnlineStore_voucherCheckValidity($code, $email)
{
if (isset($GLOBALS['OnlineStore_voucherInstance'])) {
return $GLOBALS['OnlineStore_voucherInstance'];
}
$rs = dbAll('select * from online_store_vouchers where code="' . addslashes($code) . '"' . ' and start_date<now() and end_date>now()');
$valid = false;
$error = __('invalid voucher code, or voucher has expired');
foreach ($rs as $voucher) {
if ($voucher['user_constraints'] == 'userlist') {
$voucher['users_list'] = json_decode($voucher['users_list'], true);
// { if you're not on the guest-list, you're not coming in!
if (!in_array($_SESSION['userdata']['id'], $voucher['users_list']['users']) && !in_array($email, $voucher['users_list']['emails'])) {
$error = __('your email address is not associated with this voucher');
continue;
}
// }
// { has the quota of voucher copies been used up?
if ($voucher['usages_in_total'] && isset($voucher['users_list']['total_uses']) && $voucher['users_list']['total_uses'] >= $voucher['usages_in_total']) {
$error = __('this voucher has been used up');
continue;
}
// }
if ($voucher['usages_per_user']) {
// { has this email address's quota been used up?
$usesbyemail = (int) @$voucher['users_list']['uses_by_email'][$email];
if ($usesbyemail >= $voucher['usages_per_user']) {
$error = __('you have used your quota of this voucher');
continue;
}
// }
// { has the user account's quota been used up?
$uid = (int) @$_SESSION['userdata']['id'];
$usesbyuser = (int) @$voucher['users_list']['uses_by_user'][$uid];
if ($uid && $usesbyuser >= $voucher['usages_per_user']) {
continue;
}
// }
}
}
$valid = $voucher;
break;
}
if (!$valid) {
return array('error' => $error);
}
$GLOBALS['OnlineStore_voucherInstance'] = $valid;
return $valid;
}
示例14: Blog_widget2
/**
* widget for blog stuff
*
* @param array $vars variables
*
* @return html
*/
function Blog_widget2($vars = null)
{
$c = '';
global $PAGEDATA;
$entry_ids = array();
if ($vars->tag) {
$rs = dbAll('select entry_id from blog_tags where tag="' . addslashes($vars->tag) . '"');
foreach ($rs as $r) {
$entry_ids[] = $r['entry_id'];
}
}
$blog_author = '';
$excerpts_offset = isset($vars->excerpts_offset) && $vars->excerpts_offset ? $vars->excerpts : 0;
$excerpts_per_page = isset($vars->excerpts) && $vars->excerpts ? $vars->excerpts : 2;
$links_prefix = $PAGEDATA->getRelativeURL();
if ($PAGEDATA->type != 'blog|blog') {
$page = PAGE::getInstanceByType('blog');
$links_prefix = $page->getRelativeURL();
}
/** @noinspection PhpUnusedLocalVariableInspection */
$excerpt_length = 100;
/** @noinspection PhpUnusedLocalVariableInspection */
$nobottomlinks = true;
if (!isset($vars->widgetType)) {
$vars->widgetType = '0';
}
switch ($vars->widgetType) {
case '1':
// { featured posts
require dirname(__FILE__) . '/featured-posts.php';
break;
// }
// }
default:
// {
if (isset($vars->imageSizeX) && $vars->imageSizeX) {
/** @noinspection PhpUnusedLocalVariableInspection */
$excerptImageSizeX = (int) $vars->imageSizeX;
}
if (isset($vars->imageSizeY) && $vars->imageSizeY) {
/** @noinspection PhpUnusedLocalVariableInspection */
$excerptImageSizeY = (int) $vars->imageSizeY;
}
require dirname(__FILE__) . '/excerpts.php';
break;
//}
}
return $c;
}
示例15: showCategoriesRecursive
function showCategoriesRecursive($pid, $level, $sid)
{
$opts = array();
$cs = dbAll('select id,name from products_categories where parent_id=' . $pid . ' order by name', false, 'products_categories');
foreach ($cs as $c) {
$opt = '<option value="' . $c['id'] . '"';
if ($c['id'] == $sid) {
$opt .= ' selected="selected"';
}
$opt .= '>' . str_repeat('» ', $level) . htmlspecialchars(__FromJson($c['name'])) . '</option>';
$opts[] = $opt;
$opts[] = showCategoriesRecursive($c['id'], $level + 1, $sid);
}
return join('', $opts);
}