function updateOptions() { if (!isset($this->_options)) { return false; } $update_sql_template = 'REPLACE INTO userdata_plugins_options values ( ' . $this->id . ', %s, %s )'; foreach ($this->_options as $option_name => $option_value) { $update_sql = sprintf($update_sql_template, $this->dbcon->qstr($option_name), $this->dbcon->qstr($option_value)); if (!$this->dbcon->Execute($update_sql)) { AMP_DebugSQL($update_sql, 'Option Update'); } } $this->dbcon->CacheFlush(); }
function assembleSQL(&$lookup) { $distinct = $lookup->distinct ? " distinct " : ""; $sql = "Select " . $distinct . $lookup->id_field . ", " . $lookup->result_field . " from " . $lookup->datatable; if ($lookup->criteria) { $sql .= " where " . $lookup->criteria; } if ($lookup->sortby) { $sql .= " order by " . $lookup->sortby; } if (AMP_DISPLAYMODE_DEBUG_LOOKUPS) { AMP_DebugSQL($sql, get_class($lookup)); } return $sql; }
function getListsByUser($user_id) { $set = array(); $this->addCriteriaUser($user_id); $sql = "SELECT listid " . $this->_makeSource() . $this->_makeCriteria(); $set = $this->dbcon->CacheGetArray($sql); if (defined($this->_debug_constant) && constant($this->_debug_constant)) { AMP_DebugSQL($sql, get_class($this) . " lookup " . $field); } $final_set = array(); foreach ($set as $key => $row) { $final_set[] = $row['listid']; } return $final_set; }
function getData($id = null) { $this->id = $id; $fieldset = array_keys($this->fields); $sql = "Select " . join(",", $fieldset) . " from " . $this->datatable; if (isset($id) && $id) { $sql .= " where id=" . $id; $datablock = $this->dbcon->Execute($sql); $dataset = $datablock->FetchRow(); $this->form->setDefaults($dataset); } else { if (isset($this->list['criteria'])) { $sql .= ' WHERE ' . join(" AND ", $this->list['criteria']); } if (isset($this->list['sort'])) { $sql .= " ORDER BY " . $this->list['sort']; } $dataset = $this->dbcon->CacheGetAll($sql); } if (AMP_DISPLAYMODE_DEBUG) { AMP_DebugSQL($sql, get_class($this)); } return $dataset; }
function getSet($options) { $list_sql = $this->_render_sql(); if (AMP_DISPLAYMODE_DEBUG) { AMP_DebugSQL($list_sql, get_class($this) . $this->instance); } $this->results = $this->dbcon->CacheGetAll($list_sql); return is_array($this->results); }
function getLookup($field, $use_sort = false) { $set = array(); if (!$this->makeReady()) { $sql = "SELECT " . $this->getIdFieldLookups() . ", {$field} " . $this->_makeSource() . $this->_makeCriteria(); if ($use_sort) { $sql .= $this->_makeSort(); } $set = $this->dbcon->CacheGetAssoc($sql); if (defined($this->_debug_constant) && constant($this->_debug_constant)) { AMP_DebugSQL($sql, get_class($this) . " lookup " . $field); } if (!$set && ($db_error = $this->dbcon->ErrorMsg())) { trigger_error(sprintf(AMP_TEXT_ERROR_LOOKUP_SQL_FAILED, get_class($this) . __FUNCTION__, $db_error) . $sql); } } else { while ($record = $this->getData()) { $set[$record['id']] = $record[$field]; } } return $set; }
function _register_plugins() { $plugins = array(); $this->plugins =& $plugins; $dbcon = $this->dbcon; $sql = "SELECT id, namespace, action FROM userdata_plugins WHERE instance_id="; $sql .= $dbcon->qstr($this->instance) . " AND active='1' ORDER BY priority"; if (AMP_DISPLAYMODE_DEBUG_PLUGINS) { AMP_DebugSQL($sql, get_class($this)); } $rs = $dbcon->CacheExecute($sql) or die("Couldn't register module data: " . $dbcon->ErrorMsg()); $r = false; if ($rs->RecordCount() != 0) { while ($plugin = $rs->FetchRow()) { $namespace = $plugin['namespace']; $action = $plugin['action']; $plugin_instance = $plugin['id']; $r =& $this->registerPlugin($namespace, $action, $plugin_instance) and $r; } } else { if (method_exists($this, '_register_default_plugins')) { $this->_register_default_plugins(); } } $this->_register_lists(); return $r; }
//echo $sql; $sqlct = "SELECT COUNT(DISTINCT id) from articles" . $sql; $listct = $dbcon->CacheExecute("{$sqlct}") or die("could not get list count" . $dbcon->ErrorMsg()); $sqlsel = "SELECT DISTINCTROW id, link, linkover, shortdesc, date, usedate, author, source, sourceurl, picuse, picture, title FROM articles"; if (isset($_GET['offset'])) { $soffset = $_GET['offset']; } else { $soffset = 0; } $sqloffset = " LIMIT {$soffset},{$limit} "; if (isset($_GET['all'])) { $sqloffset = ""; } $sql = $sqlsel . $sql . $sqloffset; if (isset($_GET['debug'])) { AMP_DebugSQL($sql, 'list_default'); } $list = $dbcon->CacheExecute("{$sql}") or die("Could not build list:<br>" . $sql . '<br>' . $dbcon->ErrorMsg()); // calll the layout file if (isset($listlayoutreplace) && $listlayoutreplace != NULL) { include "{$listlayoutreplace}"; } else { include "AMP/List/list.layout.inc.php"; } // show pagination if ($limit < $listct->fields[0]) { echo '<br><br><div align="right">'; $MM_removeList = "&offset=, &all=,&nointro="; reset($_GET); if (!isset($MM_keepURL)) { $MM_keepURL = "";
function fof_do_query($sql, $live = 0) { $dbcon = AMP_Registry::getDbcon(); // echo "[$sql]<br>"; if (AMP_DISPLAYMODE_DEBUG) { AMP_DebugSQL($sql, 'Feeds on Feeds'); } if ($live) { return $dbcon->Execute($sql); } else { $result = $dbcon->Execute($sql); if (!$result) { die("Cannot query database. Have you run <a href=\"install.php\"><code>install.php</code></a>? MySQL says: <b>" . $dbcon->ErrorMsg() . "</b>"); } return $result; } }
function &return_items($fieldset, $criteria, $orderby = null, $return_qty = "*", $offset = 0) { $empty_value = false; $sql = "SELECT {$fieldset} from userdata "; if (is_array($criteria) && !empty($criteria)) { $sql .= "where " . join(" AND ", $criteria); } $sql .= isset($orderby) ? " ORDER BY " . $orderby : ""; if ($pager = $this->udm->getPlugins('Pager')) { $pager =& $pager[key($pager)]; $sql .= $pager->return_qty != "*" ? " LIMIT " . strval($pager->offset) . ", " . strval($pager->return_qty) : ""; } else { $sql .= $return_qty != "*" ? " LIMIT " . strval($offset) . ", " . strval($return_qty) : ""; } if (AMP_DISPLAYMODE_DEBUG) { AMP_DebugSQL($sql, "udmsearch"); } if ($dataset = $this->dbcon->CacheExecute($sql)) { return $dataset; } else { return $empty_value; } }
function _countSqlItems($sql) { $start_crit = strpos(strtoupper($sql), "FROM "); if ($start_crit === FALSE) { return; } $count_sql = "SELECT count(*) as AMPqty " . substr($sql, $start_crit); if (AMP_DISPLAYMODE_DEBUG_NAVS) { AMP_DebugSQL($count_sql, $this->nav->getName() . " count"); } if ($result = $this->nav->dbcon->CacheExecute($count_sql)) { return $this->nav->setCount($result->Fields("AMPqty")); } if ($error = $this->nav->dbcon->ErrorMsg()) { trigger_error($this->nav->getName() . ' nav count failed: ' . $error); } return false; }
function clearEventCache($cal_id) { $sql = "SELECT * FROM calendar WHERE "; $sql .= "id='" . $cal_id . "'"; $this->dbcon->CacheFlush(); if (defined($this->_debug_cache_constant) && constant($this->_debug_cache_constant)) { AMP_DebugSQL($sql, get_class($this) . " cleared cache"); } }
function clearItemCache($id) { $sql = $this->_assembleSqlByID($id); $this->dbcon->CacheFlush($sql); if (defined($this->_debug_cache_constant) && constant($this->_debug_cache_constant)) { AMP_DebugSQL($sql, get_class($this) . " cleared cache"); } $data_set =& $this->_getSearchSource(); $data_set->clearCache(); }
function return_events($fieldset, $criteria, $orderby = null, $return_qty = "*", $offset = 0) { $sql = "SELECT {$fieldset} from calendar where " . join(" AND ", $criteria); $sql .= isset($orderby) ? " ORDER BY " . $orderby : ""; if ($pager =& $this->calendar->getPlugin('Output', 'Pager')) { $sql .= $pager->return_qty != "*" ? " LIMIT " . strval($pager->offset) . ", " . strval($pager->return_qty) : ""; } else { $sql .= $return_qty != "*" ? " LIMIT " . strval($offset) . ", " . strval($return_qty) : ""; } if (AMP_DISPLAYMODE_DEBUG) { AMP_DebugSQL($sql, "calendar_main"); } if ($eventset = $this->dbcon->CacheGetAll($sql)) { return $eventset; } else { return false; } }
function get_index($index_col = null, $orderby = null) { $options = $this->getOptions(); if (!$options['show_jumplist']) { return false; } if (isset($this->_index_set)) { return $this->_index_set; } $criteria = $this->udm->sql_criteria; if (!isset($this->udm->sortby)) { $this->udm->setSort(); } if (!isset($index_col)) { $index_col = $this->udm->sortby['select']; } if (!isset($orderby)) { $orderby = $this->udm->sortby['orderby']; } $index_sql = "SELECT " . $index_col . " from userdata "; if (is_array($criteria)) { $index_sql .= "where " . join(" AND ", $criteria); } if (isset($orderby)) { $index_sql .= " ORDER BY " . $orderby; } if (AMP_DISPLAYMODE_DEBUG) { AMP_DebugSQL($index_sql, "udm_pager"); } if ($indexset =& $this->dbcon->CacheGetAll($index_sql)) { $this->_index_set = $indexset; return $indexset; } return false; }
} $sqlct = "SELECT COUNT(DISTINCT id) from articles" . $sql; $listct = $dbcon->CacheExecute("{$sqlct}") or die($dbcon->ErrorMsg()); $sqlsel = "SELECT DISTINCTROW id, link, linkover, shortdesc, date, usedate, author, source, source, sourceurl, picuse, picture, title FROM articles"; if (isset($_GET[offset])) { $soffset = $_GET[offset]; } else { $soffset = 0; } $sqloffset = " LIMIT {$soffset},{$limit} "; if (isset($_GET[all])) { $sqloffset = ""; } $sql = $sqlsel . $sql . $sqloffset; if (isset($_GET['debug'])) { AMP_DebugSQL($sql, 'list_general'); } $list = $dbcon->CacheExecute("{$sql}") or die($dbcon->ErrorMsg()); if ($listlayoutreplace != NULL) { include "{$listlayoutreplace}"; } else { include "AMP/List/list.layout.inc.php"; } ?> <br><br> <div align="right">