当前位置: 首页>>代码示例>>PHP>>正文


PHP array_from_query函数代码示例

本文整理汇总了PHP中array_from_query函数的典型用法代码示例。如果您正苦于以下问题:PHP array_from_query函数的具体用法?PHP array_from_query怎么用?PHP array_from_query使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了array_from_query函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_cat_id_from_permalink

/** returns a category id that corresponds to the given permalink (or null)
 * @param string permalink
 */
function get_cat_id_from_permalink($permalink)
{
    $query = '
SELECT id FROM ' . CATEGORIES_TABLE . '
  WHERE permalink=\'' . $permalink . '\'';
    $ids = array_from_query($query, 'id');
    if (!empty($ids)) {
        return $ids[0];
    }
    return null;
}
开发者ID:donseba,项目名称:Piwigo,代码行数:14,代码来源:functions_permalinks.php

示例2: flickr_perform_batch_manager_prefilters

   function flickr_perform_batch_manager_prefilters($filter_sets, $prefilter)
   {
       if ($prefilter == 'flickr') {
           $query = '
 SELECT id
   FROM ' . IMAGES_TABLE . '
   WHERE file LIKE "flickr-%"
 ;';
           $filter_sets[] = array_from_query($query, 'id');
       }
       return $filter_sets;
   }
开发者ID:biffhero,项目名称:Flickr2Piwigo,代码行数:12,代码来源:main.inc.php

示例3: vjs_perform_batch_manager_prefilters

function vjs_perform_batch_manager_prefilters($filter_sets, $prefilter)
{
    if ($prefilter === "videojs0") {
        $filter = "";
    } else {
        if ($prefilter === "videojs1") {
            $filter = "AND `representative_ext` IS NOT NULL";
        } else {
            if ($prefilter === "videojs2") {
                $filter = "AND `representative_ext` IS NULL";
            }
        }
    }
    if (isset($filter)) {
        $query = "SELECT id FROM " . IMAGES_TABLE . " WHERE " . SQL_VIDEOS . " " . $filter;
        $filter_sets[] = array_from_query($query, 'id');
    }
    return $filter_sets;
}
开发者ID:naryoss,项目名称:piwigo-videojs,代码行数:19,代码来源:admin_batchmanager.php

示例4: osm_perform_batch_manager_prefilters

function osm_perform_batch_manager_prefilters($filter_sets, $prefilter)
{
    if ($prefilter === "osm0") {
        $filter = "`latitude` IS NOT NULL and `longitude` IS NOT NULL";
    } else {
        if ($prefilter === "osm1") {
            $filter = "`latitude` IS NULL OR `longitude` IS NULL";
        } else {
            if ($prefilter === "osm2") {
                $filter = "`path` LIKE '%gpx%'";
            }
        }
    }
    if (isset($filter)) {
        $query = "SELECT id FROM " . IMAGES_TABLE . " WHERE " . $filter;
        $filter_sets[] = array_from_query($query, 'id');
    }
    return $filter_sets;
}
开发者ID:joubu,项目名称:piwigo-openstreetmap,代码行数:19,代码来源:admin_batchmanager.php

示例5: array_from_query

SELECT
    id AS group_id
  FROM ' . GROUPS_TABLE . '
;';
$all_group_ids = array_from_query($query, 'group_id');
if (count($all_group_ids) == 0) {
    $template->assign('no_group_in_gallery', true);
} else {
    if ('private' == $category['status']) {
        $query = '
SELECT
    group_id
  FROM ' . GROUP_ACCESS_TABLE . '
  WHERE cat_id = ' . $category['id'] . '
;';
        $group_ids = array_from_query($query, 'group_id');
        if (count($group_ids) == 0) {
            $template->assign('permission_url', $admin_album_base_url . '-permissions');
        }
    } else {
        $group_ids = $all_group_ids;
    }
    if (count($group_ids) > 0) {
        $query = '
SELECT
    id,
    name
  FROM ' . GROUPS_TABLE . '
  WHERE id IN (' . implode(',', $group_ids) . ')
  ORDER BY name ASC
;';
开发者ID:donseba,项目名称:Piwigo,代码行数:31,代码来源:album_notification.php

示例6: array_from_query

                            } else {
                                if (!in_array('rotation', $columns_of[PREFIX_TABLE . 'images'])) {
                                    $current_release = '2.3.0';
                                } else {
                                    if (!in_array('website_url', $columns_of[PREFIX_TABLE . 'comments'])) {
                                        $current_release = '2.4.0';
                                    } else {
                                        if (!in_array('nb_available_tags', $columns_of[PREFIX_TABLE . 'user_cache'])) {
                                            $current_release = '2.5.0';
                                        } else {
                                            // retrieve already applied upgrades
                                            $query = '
SELECT id
  FROM ' . PREFIX_TABLE . 'upgrade
;';
                                            $applied_upgrades = array_from_query($query, 'id');
                                            if (!in_array(144, $applied_upgrades)) {
                                                $current_release = '2.6.0';
                                            } else {
                                                // confirm that the database is in the same version as source code files
                                                conf_update_param('piwigo_db_version', get_branch_from_version(PHPWG_VERSION));
                                                header('Content-Type: text/html; charset=' . get_pwg_charset());
                                                echo 'No upgrade required, the database structure is up to date';
                                                echo '<br><a href="index.php">← back to gallery</a>';
                                                exit;
                                            }
                                        }
                                    }
                                }
                            }
                        }
开发者ID:RioPwg,项目名称:Piwigo,代码行数:31,代码来源:upgrade.php

示例7: get_regular_search_results

/**
 * Returns the list of items corresponding to the advanced search array.
 *
 * @param array $search
 * @param string $images_where optional additional restriction on images table
 * @return array
 */
function get_regular_search_results($search, $images_where = '')
{
    global $conf;
    $forbidden = get_sql_condition_FandF(array('forbidden_categories' => 'category_id', 'visible_categories' => 'category_id', 'visible_images' => 'id'), "\n  AND");
    $items = array();
    $tag_items = array();
    if (isset($search['fields']['tags'])) {
        $tag_items = get_image_ids_for_tags($search['fields']['tags']['words'], $search['fields']['tags']['mode']);
    }
    $search_clause = get_sql_search_clause($search);
    if (!empty($search_clause)) {
        $query = '
SELECT DISTINCT(id)
  FROM ' . IMAGES_TABLE . ' i
    INNER JOIN ' . IMAGE_CATEGORY_TABLE . ' AS ic ON id = ic.image_id
  WHERE ' . $search_clause;
        if (!empty($images_where)) {
            $query .= "\n  AND " . $images_where;
        }
        $query .= $forbidden . '
  ' . $conf['order_by'];
        $items = array_from_query($query, 'id');
    }
    if (!empty($tag_items)) {
        switch ($search['mode']) {
            case 'AND':
                if (empty($search_clause)) {
                    $items = $tag_items;
                } else {
                    $items = array_values(array_intersect($items, $tag_items));
                }
                break;
            case 'OR':
                $before_count = count($items);
                $items = array_unique(array_merge($items, $tag_items));
                break;
        }
    }
    return $items;
}
开发者ID:lcorbasson,项目名称:Piwigo,代码行数:47,代码来源:functions_search.inc.php

示例8: check_upgrade_feed

/**
 * returns true if there are available upgrade files
 */
function check_upgrade_feed()
{
    // retrieve already applied upgrades
    $query = '
SELECT id
  FROM ' . UPGRADE_TABLE . '
;';
    $applied = array_from_query($query, 'id');
    // retrieve existing upgrades
    $existing = get_available_upgrade_ids();
    // which upgrades need to be applied?
    return count(array_diff($existing, $applied)) > 0;
}
开发者ID:lcorbasson,项目名称:Piwigo,代码行数:16,代码来源:functions_upgrade.php

示例9: get_history

/**
 * Perform history search.
 *
 * @param array $data  - used in trigger_change
 * @param array $search
 * @param string[] $types
 * @param array
 */
function get_history($data, $search, $types)
{
    if (isset($search['fields']['filename'])) {
        $query = '
SELECT
    id
  FROM ' . IMAGES_TABLE . '
  WHERE file LIKE \'' . $search['fields']['filename'] . '\'
;';
        $search['image_ids'] = array_from_query($query, 'id');
    }
    // echo '<pre>'; print_r($search); echo '</pre>';
    $clauses = array();
    if (isset($search['fields']['date-after'])) {
        $clauses[] = "date >= '" . $search['fields']['date-after'] . "'";
    }
    if (isset($search['fields']['date-before'])) {
        $clauses[] = "date <= '" . $search['fields']['date-before'] . "'";
    }
    if (isset($search['fields']['types'])) {
        $local_clauses = array();
        foreach ($types as $type) {
            if (in_array($type, $search['fields']['types'])) {
                $clause = 'image_type ';
                if ($type == 'none') {
                    $clause .= 'IS NULL';
                } else {
                    $clause .= "= '" . $type . "'";
                }
                $local_clauses[] = $clause;
            }
        }
        if (count($local_clauses) > 0) {
            $clauses[] = implode(' OR ', $local_clauses);
        }
    }
    if (isset($search['fields']['user']) and $search['fields']['user'] != -1) {
        $clauses[] = 'user_id = ' . $search['fields']['user'];
    }
    if (isset($search['fields']['image_id'])) {
        $clauses[] = 'image_id = ' . $search['fields']['image_id'];
    }
    if (isset($search['fields']['filename'])) {
        if (count($search['image_ids']) == 0) {
            // a clause that is always false
            $clauses[] = '1 = 2 ';
        } else {
            $clauses[] = 'image_id IN (' . implode(', ', $search['image_ids']) . ')';
        }
    }
    if (isset($search['fields']['ip'])) {
        $clauses[] = 'IP LIKE "' . $search['fields']['ip'] . '"';
    }
    $clauses = prepend_append_array_items($clauses, '(', ')');
    $where_separator = implode("\n    AND ", $clauses);
    $query = '
SELECT
    date,
    time,
    user_id,
    IP,
    section,
    category_id,
    tag_ids,
    image_id,
    image_type
  FROM ' . HISTORY_TABLE . '
  WHERE ' . $where_separator . '
;';
    // LIMIT '.$conf['nb_logs_page'].' OFFSET '.$page['start'].'
    $result = pwg_query($query);
    while ($row = pwg_db_fetch_assoc($result)) {
        $data[] = $row;
    }
    return $data;
}
开发者ID:donseba,项目名称:Piwigo,代码行数:84,代码来源:functions_history.inc.php

示例10: IN

  SET polaroid_active = \'true\'
  WHERE id IN (' . implode(',', $_POST['albums']) . ')
;';
        pwg_query($query);
    }
    $page['infos'][] = l10n('Your configuration settings are saved');
}
// +-----------------------------------------------------------------------+
// | template init                                                         |
// +-----------------------------------------------------------------------+
$template->set_filename('plugin_admin_content', dirname(__FILE__) . '/admin_config.tpl');
// +-----------------------------------------------------------------------+
// | form options                                                          |
// +-----------------------------------------------------------------------+
// associate to albums
$query = '
SELECT id
  FROM ' . CATEGORIES_TABLE . '
  WHERE polaroid_active = \'true\'
;';
$polaroid_albums = array_from_query($query, 'id');
$query = '
SELECT id,name,uppercats,global_rank
  FROM ' . CATEGORIES_TABLE . '
;';
display_select_cat_wrapper($query, $polaroid_albums, 'album_options');
$template->assign('apply_to_albums', $conf['polaroid']['apply_to_albums']);
// +-----------------------------------------------------------------------+
// | sending html code                                                     |
// +-----------------------------------------------------------------------+
$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
开发者ID:plegall,项目名称:Piwigo-polaroid,代码行数:31,代码来源:admin_config.php

示例11: define

define('PHPWG_ROOT_PATH', './');
include_once PHPWG_ROOT_PATH . 'include/common.inc.php';
// +-----------------------------------------------------------------------+
// | Check Access and exit when user status is not ok                      |
// +-----------------------------------------------------------------------+
check_status(ACCESS_GUEST);
if (empty($_GET['q'])) {
    redirect(make_index_url());
}
$search = array();
$search['q'] = $_GET['q'];
$query = '
SElECT id FROM ' . SEARCH_TABLE . '
  WHERE rules = \'' . addslashes(serialize($search)) . '\'
;';
$search_id = array_from_query($query, 'id');
if (!empty($search_id)) {
    $search_id = $search_id[0];
    $query = '
UPDATE ' . SEARCH_TABLE . '
  SET last_seen=NOW()
  WHERE id=' . $search_id;
    pwg_query($query);
} else {
    $query = '
INSERT INTO ' . SEARCH_TABLE . '
  (rules, last_seen)
  VALUES
  (\'' . addslashes(serialize($search)) . '\', NOW() )
;';
    pwg_query($query);
开发者ID:donseba,项目名称:Piwigo,代码行数:31,代码来源:qsearch.php

示例12: ws_caddie_add

/**
 * API method
 * Adds images to the caddie
 * @param mixed[] $params
 *    @option int[] image_id
 */
function ws_caddie_add($params, &$service)
{
    global $user;
    $query = '
SELECT id
  FROM ' . IMAGES_TABLE . '
      LEFT JOIN ' . CADDIE_TABLE . '
      ON id=element_id AND user_id=' . $user['id'] . '
  WHERE id IN (' . implode(',', $params['image_id']) . ')
    AND element_id IS NULL
;';
    $result = array_from_query($query, 'id');
    $datas = array();
    foreach ($result as $id) {
        $datas[] = array('element_id' => $id, 'user_id' => $user['id']);
    }
    if (count($datas)) {
        mass_inserts(CADDIE_TABLE, array('element_id', 'user_id'), $datas);
    }
    return count($datas);
}
开发者ID:donseba,项目名称:Piwigo,代码行数:27,代码来源:pwg.php

示例13: l10n

    // photo in the selection
    $groups = $_POST['group_selection'];
    if (count($groups) == 0) {
        $page['errors'][] = l10n('Select at least one group');
    }
    $action = $_POST['selectAction'];
    // +
    // |rename a group
    // +
    if ($action == "rename") {
        // is the group not already existing ?
        $query = '
SELECT name
  FROM ' . GROUPS_TABLE . '
;';
        $group_names = array_from_query($query, 'name');
        foreach ($groups as $group) {
            if (in_array($_POST['rename_' . $group . ''], $group_names)) {
                $page['errors'][] = $_POST['rename_' . $group . ''] . ' | ' . l10n('This name is already used by another group.');
            } elseif (!empty($_POST['rename_' . $group . ''])) {
                $query = '
        UPDATE ' . GROUPS_TABLE . '
        SET name = \'' . pwg_db_real_escape_string($_POST['rename_' . $group . '']) . '\'
        WHERE id = ' . $group . '
      ;';
                pwg_query($query);
            }
        }
    }
    // +
    // |delete a group
开发者ID:donseba,项目名称:Piwigo,代码行数:31,代码来源:group_list.php

示例14: initialize_calendar


//.........这里部分代码省略.........
    if (!isset($page['chronology_view']) or !in_array($page['chronology_view'], $views)) {
        $page['chronology_view'] = CAL_VIEW_LIST;
    }
    if (CAL_VIEW_CALENDAR == $page['chronology_view'] and !$styles[$cal_style]['view_calendar']) {
        $page['chronology_view'] = CAL_VIEW_LIST;
    }
    // perform a sanity check on $requested
    if (!isset($page['chronology_date'])) {
        $page['chronology_date'] = array();
    }
    while (count($page['chronology_date']) > 3) {
        array_pop($page['chronology_date']);
    }
    $any_count = 0;
    for ($i = 0; $i < count($page['chronology_date']); $i++) {
        if ($page['chronology_date'][$i] == 'any') {
            if ($page['chronology_view'] == CAL_VIEW_CALENDAR) {
                // we dont allow any in calendar view
                while ($i < count($page['chronology_date'])) {
                    array_pop($page['chronology_date']);
                }
                break;
            }
            $any_count++;
        } elseif ($page['chronology_date'][$i] == '') {
            while ($i < count($page['chronology_date'])) {
                array_pop($page['chronology_date']);
            }
        } else {
            $page['chronology_date'][$i] = (int) $page['chronology_date'][$i];
        }
    }
    if ($any_count == 3) {
        array_pop($page['chronology_date']);
    }
    $calendar->initialize($inner_sql);
    //echo ('<pre>'. var_export($calendar, true) . '</pre>');
    $must_show_list = true;
    // true until calendar generates its own display
    if (script_basename() != 'picture') {
        if ($calendar->generate_category_content()) {
            $page['items'] = array();
            $must_show_list = false;
        }
        $page['comment'] = '';
        $template->assign('FILE_CHRONOLOGY_VIEW', 'month_calendar.tpl');
        foreach ($styles as $style => $style_data) {
            foreach ($views as $view) {
                if ($style_data['view_calendar'] or $view != CAL_VIEW_CALENDAR) {
                    $selected = false;
                    if ($style != $cal_style) {
                        $chronology_date = array();
                        if (isset($page['chronology_date'][0])) {
                            $chronology_date[] = $page['chronology_date'][0];
                        }
                    } else {
                        $chronology_date = $page['chronology_date'];
                    }
                    $url = duplicate_index_url(array('chronology_style' => $style, 'chronology_view' => $view, 'chronology_date' => $chronology_date));
                    if ($style == $cal_style and $view == $page['chronology_view']) {
                        $selected = true;
                    }
                    $template->append('chronology_views', array('VALUE' => $url, 'CONTENT' => l10n('chronology_' . $style . '_' . $view), 'SELECTED' => $selected));
                }
            }
        }
        $url = duplicate_index_url(array(), array('start', 'chronology_date'));
        $calendar_title = '<a href="' . $url . '">' . $fields[$page['chronology_field']]['label'] . '</a>';
        $calendar_title .= $calendar->get_display_name();
        $template->assign('chronology', array('TITLE' => $calendar_title));
    }
    // end category calling
    if ($must_show_list) {
        if (isset($page['super_order_by'])) {
            $order_by = $conf['order_by'];
        } else {
            if (count($page['chronology_date']) == 0 or in_array('any', $page['chronology_date'])) {
                // selected period is very big so we show newest first
                $order = ' DESC, ';
            } else {
                // selected period is small (month,week) so we show oldest first
                $order = ' ASC, ';
            }
            $order_by = str_replace('ORDER BY ', 'ORDER BY ' . $calendar->date_field . $order, $conf['order_by']);
        }
        if ('categories' == $page['section'] && !isset($page['category']) && (count($page['chronology_date']) == 0 or $page['chronology_date'][0] == 'any' && count($page['chronology_date']) == 1)) {
            $cache_key = $persistent_cache->make_key($user['id'] . $user['cache_update_time'] . $calendar->date_field . $order_by);
        }
        if (!isset($cache_key) || !$persistent_cache->get($cache_key, $page['items'])) {
            $query = 'SELECT DISTINCT id ' . $calendar->inner_sql . '
  ' . $calendar->get_date_where() . '
  ' . $order_by;
            $page['items'] = array_from_query($query, 'id');
            if (isset($cache_key)) {
                $persistent_cache->set($cache_key, $page['items']);
            }
        }
    }
    pwg_debug('end initialize_calendar');
}
开发者ID:lcorbasson,项目名称:Piwigo,代码行数:101,代码来源:functions_calendar.inc.php

示例15: pwg_query

pwg_query($query);
//
// replace gallery_description by page_banner
//
$query = '
SELECT value
  FROM ' . PREFIX_TABLE . 'config
  WHERE param=\'gallery_title\'
;';
list($t) = array_from_query($query, 'value');
$query = '
SELECT value
  FROM ' . PREFIX_TABLE . 'config
  WHERE param=\'gallery_description\'
;';
list($d) = array_from_query($query, 'value');
$page_banner = '<h1>' . $t . '</h1><p>' . $d . '</p>';
$page_banner = addslashes($page_banner);
$query = '
INSERT INTO ' . PREFIX_TABLE . 'config
  (param,value,comment)
  VALUES
  (
    \'page_banner\',
    \'' . $page_banner . '\',
    \'html displayed on the top each page of your gallery\'
  )
;';
pwg_query($query);
$query = '
DELETE FROM ' . PREFIX_TABLE . 'config
开发者ID:squidjam,项目名称:Piwigo,代码行数:31,代码来源:upgrade_1.5.0.php


注:本文中的array_from_query函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。