本文整理汇总了PHP中Channel::build_sql_query方法的典型用法代码示例。如果您正苦于以下问题:PHP Channel::build_sql_query方法的具体用法?PHP Channel::build_sql_query怎么用?PHP Channel::build_sql_query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Channel
的用法示例。
在下文中一共展示了Channel::build_sql_query方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
function _build_query()
{
// Do something awesome
$allowed_params = array('by', 'channel', 'author_id', 'category', 'category_group', 'entry_id_from', 'entry_id_to', 'group_id', 'show_expired', 'show_future_entries', 'status', 'start_on', 'stop_before', 'uncategorized_entries', 'username');
foreach ($this->EE->TMPL->tagparams as $param => $val) {
if (!in_array($param, $allowed_params)) {
unset($this->EE->TMPL->tagparams[$param]);
}
}
$this->EE->TMPL->tagparams['dynamic'] = 'off';
if (!class_exists('Channel')) {
require PATH_MOD . 'channel/mod.channel.php';
}
$C = new Channel();
$C->build_sql_query();
if ($C->sql == '') {
return $this->EE->TMPL->no_results();
}
$this->query = $this->EE->db->query($C->sql);
if ($this->query->num_rows() == 0) {
return $this->EE->TMPL->no_results();
}
foreach ($this->query->result() as $entry) {
$loc = $this->EE->localize->set_localized_time($entry->entry_date);
$day = intval(date('d', $loc));
$month = intval(date('m', $loc));
$year = intval(date('Y', $loc));
switch ($this->by) {
default:
case 'day':
$this->periods[] = mktime(0, 0, 0, $month, $day, $year);
break;
case 'month':
$this->periods[] = mktime(0, 0, 0, $month, 1, $year);
break;
case 'year':
$this->periods[] = mktime(0, 0, 0, 1, 1, $year);
break;
}
}
$this->periods = array_unique($this->periods);
rsort($this->periods);
$cnt = count($this->periods) - 1;
$currIndex = array_search($this->current, $this->periods);
if ($currIndex === false) {
$this->periods[] = $this->current;
$this->periods = array_unique($this->periods);
rsort($this->periods);
$currIndex = array_search($this->current, $this->periods);
}
$this->oldest = isset($this->periods[$cnt]) && $this->periods[$cnt] != $this->current ? $this->periods[$cnt] : 0;
$this->older = isset($this->periods[$currIndex + 1]) ? $this->periods[$currIndex + 1] : 0;
$this->newer = isset($this->periods[$currIndex - 1]) ? $this->periods[$currIndex - 1] : 0;
$this->newest = isset($this->periods[0]) && $this->periods[0] != $this->current ? $this->periods[0] : 0;
}
示例2: rank
//.........这里部分代码省略.........
$channel->pagination->dynamic_sql = FALSE;
}
// ----------------------------------------
// Pre-process related data
// ----------------------------------------
// TMPL class is coded so that only
// one method in the weblog class and one
// method in the search class are allowed
// to parse related entries tags. This is
// no doubt for performance reasons.
// ----------------------------------------
ee()->TMPL->tagdata = ee()->TMPL->assign_relationship_data(ee()->TMPL->tagdata);
ee()->TMPL->var_single = array_merge(ee()->TMPL->var_single, ee()->TMPL->related_markers);
// ----------------------------------------
// Execute needed methods
// ----------------------------------------
if (APP_VER < 2.0) {
$channel->fetch_custom_weblog_fields();
} else {
$channel->fetch_custom_channel_fields();
}
$channel->fetch_custom_member_fields();
// --------------------------------------------
// Pagination Tags Parsed Out
// --------------------------------------------
if (APP_VER >= '2.4.0') {
$channel->pagination->get_template();
} else {
$channel->fetch_pagination_data();
}
// ----------------------------------------
// Build Weblog Data Query
// ----------------------------------------
$channel->build_sql_query();
// --------------------------------------------
// Transfer Pagination Variables Over to Channel object
// - Has to go after the building of the query as EE 2.4 does its Pagination work in there
// --------------------------------------------
if (APP_VER >= '2.4.0') {
$transfer = array('paginate' => 'paginate', 'total_pages' => 'total_pages', 'current_page' => 'current_page', 'offset' => 'offset', 'page_next' => 'page_next', 'page_previous' => 'page_previous', 'page_links' => 'pagination_links', 'total_rows' => 'total_rows', 'per_page' => 'per_page', 'per_page' => 'p_limit', 'offset' => 'p_page');
foreach ($transfer as $from => $to) {
$channel->{$to} = $channel->pagination->{$from};
}
}
// ----------------------------------------
// Empty?
// ----------------------------------------
if (trim($channel->sql) == '') {
if ($this->check_yes(ee()->TMPL->fetch_param('favorites_count'))) {
return $this->return_data = str_replace(LD . 'favorites_count' . RD, '0', ee()->TMPL->tagdata);
} else {
return $this->no_results();
}
}
// ----------------------------------------
// Pagination
// ----------------------------------------
$query = ee()->db->query(preg_replace("/SELECT(.*?)\\s+FROM\\s+/is", 'SELECT COUNT(*) AS count FROM ', $channel->sql));
$this->total_rows = $query->row('count');
//pagination request but no entries?
if ($query->row('count') == 0 and strpos(ee()->TMPL->tagdata, 'paginate') !== FALSE) {
return $this->no_results();
}
//$sql_remove = 'SELECT t.entry_id ';
//get pagination info
$pagination_data = $this->universal_pagination(array('sql' => $channel->sql, 'total_results' => $this->total_rows, 'tagdata' => ee()->TMPL->tagdata, 'limit' => $this->p_limit, 'uri_string' => ee()->uri->uri_string, 'current_page' => $this->current_page));
示例3: implode
function tell_a_friend()
{
if ($this->EE->uri->query_string == '') {
return FALSE;
}
/** ----------------------------------------
/** Recipient Email Checking
/** ----------------------------------------*/
$user_recipients = true;
// By default
$recipients = !$this->EE->TMPL->fetch_param('recipients') ? '' : $this->EE->TMPL->fetch_param('recipients');
$charset = !$this->EE->TMPL->fetch_param('charset') ? '' : $this->EE->TMPL->fetch_param('charset');
$allow_html = !$this->EE->TMPL->fetch_param('allow_html') ? 'n' : $this->EE->TMPL->fetch_param('allow_html');
if (!$this->EE->TMPL->fetch_param('status')) {
$this->EE->TMPL->tagparams['status'] = 'open';
}
// Clean and check recipient emails, if any
if ($recipients != '') {
$array = $this->validate_recipients($recipients);
// Put together into string again
$recipients = implode(',', $array['approved']);
}
/** --------------------------------------
/** Parse page number
/** --------------------------------------*/
// We need to strip the page number from the URL for two reasons:
// 1. So we can create pagination links
// 2. So it won't confuse the query with an improper proper ID
$qstring = $this->EE->uri->query_string;
if (preg_match("#/P(\\d+)#", $qstring, $match)) {
$current_page = $match['1'];
$qstring = $this->EE->functions->remove_double_slashes(str_replace($match['0'], '', $qstring));
}
/** --------------------------------------
/** Remove "N"
/** --------------------------------------*/
// The recent comments feature uses "N" as the URL indicator
// It needs to be removed if presenst
if (preg_match("#/N(\\d+)#", $qstring, $match)) {
$qstring = $this->EE->functions->remove_double_slashes(str_replace($match['0'], '', $qstring));
}
/* -------------------------------------
/* 'email_module_tellafriend_override' hook.
/* - Allow use of Tell-A-Friend for things besides channel entries
/* - Added EE 1.5.1
*/
if ($this->EE->extensions->active_hook('email_module_tellafriend_override') === TRUE) {
$tagdata = $this->EE->extensions->call('email_module_tellafriend_override', $qstring, $this);
if ($this->EE->extensions->end_script === TRUE) {
return $tagdata;
}
} else {
$entry_id = trim($qstring);
// If there is a slash in the entry ID we'll kill everything after it.
$entry_id = preg_replace("#/.+#", "", $entry_id);
/** ----------------------------------------
/** Do we have a vaild channel and ID number?
/** ----------------------------------------*/
$timestamp = $this->EE->TMPL->cache_timestamp != '' ? $this->EE->localize->set_gmt($this->EE->TMPL->cache_timestamp) : $this->EE->localize->now;
$channel = !$this->EE->TMPL->fetch_param('channel') ? '' : $this->EE->TMPL->fetch_param('channel');
$sql = "SELECT entry_id FROM exp_channel_titles, exp_channels\n\t\t\t\t\t\tWHERE exp_channel_titles.channel_id = exp_channels.channel_id\n\t\t\t\t\t\tAND (expiration_date = 0 OR expiration_date > " . $timestamp . ")\n\t\t\t\t\t\tAND status != 'closed' AND ";
$sql .= !is_numeric($entry_id) ? " url_title = '" . $entry_id . "' " : " entry_id = '{$entry_id}' ";
if ($channel != '') {
$sql .= $this->EE->functions->sql_andor_string($channel, 'exp_channels.channel_name') . " ";
}
$query = $this->EE->db->query($sql);
// Bad ID? See ya!
if ($query->num_rows() == 0) {
return FALSE;
}
/** ----------------------------------------
/** Fetch the channel entry
/** ----------------------------------------*/
if (!class_exists('Channel')) {
require PATH_MOD . 'channel/mod.channel' . EXT;
}
$channel = new Channel();
$channel->fetch_custom_channel_fields();
$channel->fetch_custom_member_fields();
$channel->build_sql_query();
if ($channel->sql == '') {
return FALSE;
}
$channel->query = $this->EE->db->query($channel->sql);
if ($channel->query->num_rows() == 0) {
return FALSE;
}
$this->EE->load->library('typography');
$this->EE->typography->initialize();
$this->EE->typography->encode_email = FALSE;
$this->EE->typography->convert_curly = FALSE;
$channel->fetch_categories();
$channel->parse_channel_entries();
$tagdata = $channel->return_data;
}
/*
/* -------------------------------------*/
/** ----------------------------------------
/** Parse conditionals
/** ----------------------------------------*/
//.........这里部分代码省略.........
示例4: search
//.........这里部分代码省略.........
if ($channel->enable['pagination'] == TRUE) {
if (version_compare(APP_VER, '2.4', '>=')) {
$channel->add_pagination_data();
} else {
$channel->fetch_pagination_data();
}
}
$save_cache = FALSE;
$channel->EE->TMPL->tagparams['dynamic'] = 'no';
//$zipLongitude.$zipLatitude.$address
if ($channel->EE->config->item('enable_sql_caching') == 'y') {
if (FALSE == ($channel->sql = $channel->fetch_cache())) {
$save_cache = TRUE;
} else {
if ($channel->EE->TMPL->fetch_param('dynamic') != 'no') {
if (preg_match("#(^|\\/)C(\\d+)#", $channel->query_string, $match) or in_array($channel->reserved_cat_segment, explode("/", $channel->query_string))) {
$channel->cat_request = TRUE;
}
}
}
if (FALSE !== ($cache = $channel->fetch_cache('pagination_count'))) {
if (FALSE !== $channel->fetch_cache('field_pagination')) {
if (FALSE !== ($pg_query = $channel->fetch_cache('pagination_query'))) {
$channel->paginate = TRUE;
$channel->field_pagination = TRUE;
$channel->create_pagination(trim($cache), $channel->EE->db->query(trim($pg_query)));
}
} else {
$channel->create_pagination(trim($cache));
}
}
}
if ($channel->sql == '') {
$channel->build_sql_query();
}
if ($channel->sql == '') {
return $channel->EE->TMPL->no_results();
}
$sql = "";
//@start geocoding
//if don't have the Latitude and Longitude, do query to google.map; ($zipLongitude == "" OR $zipLatitude == "") AND
if ($address != "" and ($zipLongitude == "" or $zipLatitude == "")) {
$GetLatLong_result = $this->GetLatLong($address, 2);
if ($GetLatLong_result != false) {
list($zipLongitude, $zipLatitude) = $GetLatLong_result;
} else {
return $this->EE->TMPL->no_results();
}
}
if ($reverse_geocoding and $address == "") {
$GetLatLong_result = $this->GetLatLong($zipLatitude . ',' . $zipLongitude, $api_key, 1);
if ($GetLatLong_result != false) {
$address = $GetLatLong_result;
} else {
return $this->EE->TMPL->no_results();
}
}
//@END geocoding
$conds['radius'] = $radius;
$tagdata = $this->EE->functions->prep_conditionals($tagdata, $conds);
$tagdata = str_replace(array('{center:long}', '{center:lat}', '{radius}'), array($zipLongitude, $zipLatitude, $radius), $tagdata);
$where_strpos = strpos($channel->sql, "WHERE");
if ($where_strpos > 0) {
$sql_entry_id = substr($channel->sql, $where_strpos + 5, strpos($channel->sql, "ORDER BY") - $where_strpos - 5);
$limit_strpos = strpos($channel->sql, "LIMIT");
$order_by = substr($channel->sql, strpos($channel->sql, "ORDER BY"), $limit_strpos);
示例5: prep_occurrences_output
//.........这里部分代码省略.........
// -------------------------------------
ee()->TMPL->tagdata = ee()->TMPL->assign_relationship_data($tagdata);
ee()->TMPL->var_single = array_merge(ee()->TMPL->var_single, ee()->TMPL->related_markers);
ee()->TMPL->var_single['entry_id'] = 'entry_id';
// -------------------------------------
// Execute needed methods
// -------------------------------------
if (APP_VER < 2.0) {
$channel->fetch_custom_weblog_fields();
} else {
$channel->fetch_custom_channel_fields();
}
$channel->fetch_custom_member_fields();
// --------------------------------------------
// Pagination Tags Parsed Out
// --------------------------------------------
if (APP_VER >= '2.4.0') {
$channel->pagination->get_template();
} else {
$channel->fetch_pagination_data();
}
// -------------------------------------
// Add occurrence_ prefix to custom fields
// -------------------------------------
foreach ($channel->cfields as $sid => $fields) {
foreach ($fields as $name => $fid) {
$channel->cfields[$sid]['occurrence_' . $name] = $fid;
unset($channel->cfields[$sid][$name]);
}
}
// -------------------------------------
// Querification
// -------------------------------------
$channel->build_sql_query();
if ($channel->sql == '') {
return $this->no_results();
}
$channel->query = ee()->db->query($channel->sql);
if ($channel->query->num_rows() == 0) {
//ee()->TMPL->log_item('Calendar: Channel module says no results, bailing');
return $this->no_results();
}
$channel->query->result = $channel->query->result_array();
// -------------------------------------
// Trim IDs and build events
// -------------------------------------
$new_ids = array();
foreach ($channel->query->result as $k => $row) {
$new_ids[$row['entry_id']] = $row['entry_id'];
}
if (empty($new_ids)) {
return $this->no_results();
}
$occurrence_data = $this->data->fetch_event_occurrences($data->default_data['entry_id']);
// -------------------------------------
// Turn these IDs into events
// -------------------------------------
$events = array();
if (!class_exists('Calendar_event')) {
require_once CALENDAR_PATH . 'calendar.event' . EXT;
}
$calendars = array();
$start_ymd = $this->P->value('date_range_start') !== FALSE ? $this->P->value('date_range_start', 'ymd') : '';
$end_ymd = $this->P->value('date_range_end') !== FALSE ? $this->P->value('date_range_end', 'ymd') : '';
foreach ($occurrence_data[$data->default_data['entry_id']] as $times) {
foreach ($times as $k => $odata) {
示例6: _entries
/**
* List of Entires for an Author, Sub-Processing for entries() method
*
* @access private
* @param array
* @return string
*/
private function _entries($params = array())
{
/** ----------------------------------------
/** Execute?
/** ----------------------------------------*/
if ($this->entry_id == '') {
return FALSE;
}
/** ----------------------------------------
/** Invoke Channel/Weblog class
/** ----------------------------------------*/
if (APP_VER < 2.0) {
if (!class_exists('Weblog')) {
require PATH_MOD . 'weblog/mod.weblog' . EXT;
}
$channel = new Weblog();
} else {
if (!class_exists('Channel')) {
require PATH_MOD . 'channel/mod.channel.php';
}
$channel = new Channel();
}
// --------------------------------------------
// Invoke Pagination for EE 2.4 and Above
// --------------------------------------------
if (APP_VER >= '2.4.0') {
ee()->load->library('pagination');
$channel->pagination = new Pagination_object('Channel');
// Used by pagination to determine whether we're coming from the cache
$channel->pagination->dynamic_sql = FALSE;
}
/** ----------------------------------------
/** Pass params
/** ----------------------------------------*/
ee()->TMPL->tagparams['entry_id'] = $this->entry_id;
ee()->TMPL->tagparams['inclusive'] = '';
if (isset($params['dynamic']) and $params['dynamic'] == "off") {
if (APP_VER < 2.0) {
ee()->TMPL->tagparams['dynamic'] = 'off';
} else {
ee()->TMPL->tagparams['dynamic'] = 'no';
}
}
/** ----------------------------------------
/** Pre-process related data
/** ----------------------------------------*/
ee()->TMPL->tagdata = ee()->TMPL->assign_relationship_data(ee()->TMPL->tagdata);
ee()->TMPL->var_single = array_merge(ee()->TMPL->var_single, ee()->TMPL->related_markers);
/** ----------------------------------------
/** Execute needed methods
/** ----------------------------------------*/
if (APP_VER < 2.0) {
$channel->fetch_custom_weblog_fields();
} else {
$channel->fetch_custom_channel_fields();
}
$channel->fetch_custom_member_fields();
// --------------------------------------------
// Pagination Tags Parsed Out
// --------------------------------------------
if (APP_VER >= '2.4.0') {
$channel->pagination->get_template();
} else {
$channel->fetch_pagination_data();
}
if (APP_VER >= '2.4.0') {
$channel->pagination->cfields = $channel->cfields;
$channel->pagination->build();
} else {
$channel->create_pagination();
}
/** ----------------------------------------
/** Grab entry data
/** ----------------------------------------*/
//$channel->create_pagination();
$channel->build_sql_query();
if ($channel->sql == '') {
return $this->no_results();
}
$channel->query = ee()->db->query($channel->sql);
if (APP_VER < 2.0) {
$channel->query->result = $channel->query->result_array();
}
if (!isset($channel->query) or $channel->query->num_rows() == 0) {
return $this->no_results();
}
if (APP_VER < 2.0) {
if (!class_exists('Typography')) {
require PATH_CORE . 'core.typography' . EXT;
}
$channel->TYPE = new Typography();
$channel->TYPE->convert_curly = FALSE;
} else {
//.........这里部分代码省略.........
示例7: tell_a_friend
/**
* Tell a friend form
*
* {exp:email:tell_a_friend charset="utf-8" allow_html='n'}
* {exp:email:tell_a_friend charset="utf-8" allow_html='<p>,<a>' recipients='sales@ellislab.com'}
* {member_email}, {member_name}, {current_time format="%Y %d %m"}
*/
public function tell_a_friend()
{
if (ee()->uri->query_string == '') {
return FALSE;
}
// Recipient Email Checking
$this->_user_recipients = 'yes';
// By default
$recipients = ee()->TMPL->fetch_param('recipients', '');
$charset = ee()->TMPL->fetch_param('charset', '');
$allow_html = ee()->TMPL->fetch_param('allow_html');
// Equalize $allow_html value
$allow_html = (is_string($allow_html) and in_array($allow_html, array('yes', 'y', 'true'))) ? TRUE : $allow_html;
$allow_html = (is_string($allow_html) and in_array($allow_html, array('no', 'n', 'false'))) ? FALSE : $allow_html;
if (!ee()->TMPL->fetch_param('status')) {
ee()->TMPL->tagparams['status'] = 'open';
}
// Clean and check recipient emails, if any
if ($recipients != '') {
$array = $this->validate_recipients($recipients);
// Put together into string again
$recipients = implode(',', $array['approved']);
}
// Parse page number
// We need to strip the page number from the URL for two reasons:
// 1. So we can create pagination links
// 2. So it won't confuse the query with an improper proper ID
// Conditionally get query string based on whether or not the page
// was accessed through the Pages module
$qstring = empty(ee()->uri->page_query_string) ? ee()->uri->query_string : ee()->uri->page_query_string;
if (preg_match("#/P(\\d+)#", $qstring, $match)) {
$current_page = $match['1'];
$qstring = reduce_double_slashes(str_replace($match[0], '', $qstring));
}
// Remove "N"
// The recent comments feature uses "N" as the URL indicator
// It needs to be removed if presenst
if (preg_match("#/N(\\d+)#", $qstring, $match)) {
$qstring = reduce_double_slashes(str_replace($match[0], '', $qstring));
}
/* -------------------------------------
/* 'email_module_tellafriend_override' hook.
/* - Allow use of Tell-A-Friend for things besides channel entries
/* - Added EE 1.5.1
*/
if (ee()->extensions->active_hook('email_module_tellafriend_override') === TRUE) {
$tagdata = ee()->extensions->call('email_module_tellafriend_override', $qstring, $this);
if (ee()->extensions->end_script === TRUE) {
return $tagdata;
}
} else {
$entry_id = trim($qstring);
// If there is a slash in the entry ID we'll kill everything after it.
$entry_id = preg_replace("#/.+#", "", $entry_id);
// Do we have a vaild channel and ID number?
$timestamp = ee()->TMPL->cache_timestamp != '' ? ee()->TMPL->cache_timestamp : ee()->localize->now;
$channel = ee()->TMPL->fetch_param('channel', '');
ee()->db->select('entry_id')->from(array('channel_titles ct', 'channels c'))->where('ct.channel_id = c.channel_id', '', FALSE)->where('(ct.expiration_date = 0 OR expiration_date > ' . $timestamp . ')', '', FALSE)->where('ct.status !=', 'closed');
$table = !is_numeric($entry_id) ? 'ct.url_title' : 'ct.entry_id';
ee()->db->where($table, $entry_id);
if ($channel != '') {
ee()->functions->ar_andor_string($channel, 'c.channel_name');
}
$query = ee()->db->get();
// Bad ID? See ya!
if ($query->num_rows() === 0) {
return FALSE;
}
// Fetch the channel entry
if (!class_exists('Channel')) {
require PATH_MOD . 'channel/mod.channel.php';
}
$channel = new Channel();
$channel->fetch_custom_channel_fields();
$channel->fetch_custom_member_fields();
$channel->build_sql_query();
if ($channel->sql == '') {
return FALSE;
}
$channel->query = ee()->db->query($channel->sql);
if ($channel->query->num_rows() === 0) {
return FALSE;
}
ee()->load->library('typography');
ee()->typography->initialize(array('encode_email' => FALSE, 'convert_curly' => FALSE));
$channel->fetch_categories();
$channel->parse_channel_entries();
$tagdata = $channel->return_data;
}
/*
/* -------------------------------------*/
// Parse conditionals
$cond = array();
//.........这里部分代码省略.........