本文整理汇总了PHP中rex_sql::setWhere方法的典型用法代码示例。如果您正苦于以下问题:PHP rex_sql::setWhere方法的具体用法?PHP rex_sql::setWhere怎么用?PHP rex_sql::setWhere使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rex_sql
的用法示例。
在下文中一共展示了rex_sql::setWhere方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: publishNews
/**
* publish a news by id & clang
* if publish-lang == all => $clang is not needed, but must be set
* @param $id
* @param $clang
* @param DateTime $time
* @return string
*/
public static function publishNews($id, $clang, DateTime $time)
{
/**
* @var array $REX
* @var i18n $I18N
*/
global $REX, $I18N;
$sql = new rex_sql();
$sql->setTable(rex_asd_news_config::getTable());
$sql->setWhere('`id` = ' . $id . ' AND `clang` = ' . $clang);
if (rex_asd_news_config::getConfig('published-lang') == 'all') {
$sql->setWhere('`id` = ' . $id);
}
$sql->setValue('publishedAt', $time->format('Y-m-d H:i'));
$sql->setValue('publishedBy', $REX['USER']->getValue('user_id'));
$sql->setValue('status', 1);
$sql->update();
$sql->setQuery('SELECT * FROM `' . rex_asd_news_config::getTable() . '` WHERE `id` = ' . $id . ' AND `clang` = ' . $clang);
return '
<td>' . $id . '</td>
<td>' . $sql->getValue('title') . '</td>
<td><span>' . $time->format('d.m.Y H:i') . '</span></td>
<td><a href="' . self::getBaseUrl($clang) . 'unpublish&id=' . $id . '" class="rex-online" onclick="return confirm(\'' . $I18N->msg('asd_news_really_unpublish') . '\');">' . $I18N->msg('asd_news_published') . '</a></td>
<td><a href="' . self::getBaseUrl($clang) . 'edit&id=' . $id . '">' . $I18N->msg('edit') . '</a></td>
<td><a href="' . self::getBaseUrl($clang) . 'delete&id=' . $id . '" onclick="return confirm(\'' . $I18N->msg('asd_news_really_delete') . '\');">' . $I18N->msg('delete') . '</a></td>
<td><a href="' . self::getBaseUrl($clang) . 'status&id=' . $id . '" class="rex-online">' . $I18N->msg('status_online') . '</a></td>';
}
示例2: checkEntrys
/**
* check if entrys exists for the addon
* @return bool
*/
public static function checkEntrys()
{
global $REX;
$sql = new rex_sql();
$sql->setTable($REX['TABLE_PREFIX'] . 'url_control_generate');
$sql->setWhere('`table` = "' . rex_asd_news_config::getTable() . '"');
$sql->select('1');
return (bool) $sql->getRows();
}
示例3:
function a724_deletePathnamesFromTable()
{
$debug = false;
// Alle Urls der Tabelle loeschen
$sqld = new rex_sql();
$sqld->setDebug($debug);
$sqld->setTable('rex_a724_frau_schultze');
$sqld->setWhere('name != "" AND url_table != "" AND url_table_parameters = ""');
$sqld->delete();
}
示例4: asd_news_deleteClang
function asd_news_deleteClang($params)
{
$id = $params['id'];
$name = $params['name'];
$sql = new rex_sql();
$sql->setTable(rex_asd_news_config::getTable());
$sql->setWhere('`clang`= ' . $id);
if ($sql->delete()) {
echo rex_info('ASD News: Neuigkeiten wurden gelöscht');
} else {
echo rex_warning('<b>ASD News Fehler:</b> Neuigkeiten aus der Sprache "' . $name . '" konnte nicht gelöscht werden');
}
}
示例5: execute
function execute()
{
// echo "DB EXECUTE";
// return;
$sql = new rex_sql();
if ($this->params["debug"]) {
$sql->debugsql = TRUE;
}
$main_table = "";
if (isset($this->action["elements"][2]) && $this->action["elements"][2] != "") {
$main_table = $this->action["elements"][2];
} else {
$main_table = $this->params["main_table"];
}
if ($main_table == "") {
$this->params["form_show"] = TRUE;
$this->params["hasWarnings"] = TRUE;
$this->params["warning_messages"][] = $this->params["Error-Code-InsertQueryError"];
return FALSE;
}
$sql->setTable($main_table);
$where = "";
if (isset($this->action["elements"][3]) && trim($this->action["elements"][3]) != "") {
$where = trim($this->action["elements"][3]);
}
// SQL Objekt mit Werten füllen
foreach ($this->elements_sql as $key => $value) {
$sql->setValue($key, $value);
if ($where != "") {
$where = str_replace('###' . $key . '###', addslashes($value), $where);
}
}
if ($where != "") {
$sql->setWhere($where);
$sql->update();
$flag = "update";
} else {
$sql->insert();
$flag = "insert";
$id = $sql->getLastId();
$this->elements_email["ID"] = $id;
// $this->elements_sql["ID"] = $id;
if ($id == 0) {
$this->params["form_show"] = TRUE;
$this->params["hasWarnings"] = TRUE;
$this->params["warning_messages"][] = $this->params["Error-Code-InsertQueryError"];
}
}
}
示例6:
static function syncCatname2Artname($params)
{
global $REX, $I18N;
$id = $params['id'];
$clang = $params['clang'];
$name = $params['data']['catname'];
if ($name != '') {
$sql = new rex_sql();
$sql->setTable($REX['TABLE_PREFIX'] . 'article');
$sql->setWhere('id=' . $id . ' AND clang=' . $clang);
$sql->setValue('name', $name);
$sql->addGlobalUpdateFields();
$sql->update();
rex_deleteCacheArticle($id, $clang);
}
}
示例7: getInsertValue
function getInsertValue($value)
{
$value = (array) $value;
$section =& $this->getSection();
// Alle vorhanden Werte löschen
$sql = new rex_sql();
$sql->setTable($this->foreignTable);
$sql->setWhere($section->_getWhereString());
$sql->delete();
// und anschließend alle neu eintragen
foreach ($value as $val) {
// Parameter aus der Ursprungstabelle mit abspeichern damit später darüber verknüpft werden kann
foreach ($section->getWhere() as $whereColName => $whereColValue) {
$sql->setValue($whereColName, $whereColValue);
}
// Den zu speichernden Wert
$sql->setValue($this->foreignField, $val);
$sql->setTable($this->foreignTable);
$sql->insert();
}
// null zurückgeben, damit zu diesem Feld nichts im rexForm gespeichert wird
return null;
}
示例8: rex_copyMeta
/**
* Kopiert die Metadaten eines Artikels in einen anderen Artikel
*
* @param $from_id ArtikelId des Artikels, aus dem kopiert werden (Quell ArtikelId)
* @param $to_id ArtikelId des Artikel, in den kopiert werden sollen (Ziel ArtikelId)
* @param [$from_clang] ClangId des Artikels, aus dem kopiert werden soll (Quell ClangId)
* @param [$to_clang] ClangId des Artikels, in den kopiert werden soll (Ziel ClangId)
* @param [$params] Array von Spaltennamen, welche kopiert werden sollen
*/
function rex_copyMeta($from_id, $to_id, $from_clang = 0, $to_clang = 0, $params = array())
{
global $REX, $REX_USER;
$from_clang = (int) $from_clang;
$to_clang = (int) $to_clang;
$from_id = (int) $from_id;
$to_id = (int) $to_id;
if (!is_array($params)) {
$params = array();
}
if ($from_id == $to_id && $from_clang == $to_clang) {
return false;
}
$gc = new rex_sql();
$gc->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article where clang='{$from_clang}' and id='{$from_id}'");
if ($gc->getRows() == 1) {
$uc = new rex_sql();
// $uc->debugsql = 1;
$uc->setTable($REX['TABLE_PREFIX'] . "article");
$uc->setWhere("clang='{$to_clang}' and id='{$to_id}'");
$uc->addGlobalUpdateFields();
foreach ($params as $key => $value) {
$var = $gc->getValue("{$value}");
$uc->setValue("{$value}", $var);
}
$uc->update();
rex_generateArticle($to_id, false);
return true;
}
return false;
}
示例9:
}
if ($func == 'delete') {
$sql = new rex_sql();
$sql->setTable(rex_asd_news_config::getTable());
$sql->setWhere('id=' . $id . ' AND clang = ' . $clang);
if ($sql->delete()) {
echo rex_info($I18N->msg('asd_news_deleted'));
} else {
echo rex_warning($sql->getError());
}
$func = '';
}
if ($func == 'unpublish') {
$sql = new rex_sql();
$sql->setTable(rex_asd_news_config::getTable());
$sql->setWhere('id=' . $id . ' AND clang = ' . $clang);
$sql->setValue('publishedAt', '0000-00-00 00:00:00');
$sql->setValue('publishedBy', 0);
$successMessage = $I18N->msg('asd_news_unpublished_s');
if (rex_asd_news_config::getConfig('published-lang') == 'all') {
$sql->setWhere('`id` = ' . $id);
$successMessage = $I18N->msg('asd_news_unpublished_m');
}
if ($sql->update()) {
echo rex_info($successMessage);
} else {
echo rex_warning($sql->getError());
}
$func = '';
}
if ($func == '') {
示例10: stripslashes
// $modultyp->setQuery("INSERT INTO ".$REX['TABLE_PREFIX']."modultyp (category_id, name, eingabe, ausgabe) VALUES ('$category_id', '$mname', '$eingabe', '$ausgabe')");
$IMOD = new rex_sql();
$IMOD->setTable($REX['TABLE_PREFIX'] . 'module');
$IMOD->setValue('name', $mname);
$IMOD->setValue('eingabe', $eingabe);
$IMOD->setValue('ausgabe', $ausgabe);
$IMOD->addGlobalCreateFields();
$message = $IMOD->insert($I18N->msg('module_added'));
} else {
$modultyp->setQuery('select * from ' . $REX['TABLE_PREFIX'] . 'module where id=' . $modul_id);
if ($modultyp->getRows() == 1) {
$old_ausgabe = $modultyp->getValue('ausgabe');
// $modultyp->setQuery("UPDATE ".$REX['TABLE_PREFIX']."modultyp SET name='$mname', eingabe='$eingabe', ausgabe='$ausgabe' WHERE id='$modul_id'");
$UMOD = new rex_sql();
$UMOD->setTable($REX['TABLE_PREFIX'] . 'module');
$UMOD->setWhere('id=' . $modul_id);
$UMOD->setValue('name', $mname);
$UMOD->setValue('eingabe', $eingabe);
$UMOD->setValue('ausgabe', $ausgabe);
$UMOD->addGlobalUpdateFields();
$message = $UMOD->update($I18N->msg('module_updated') . ' | ' . $I18N->msg('articel_updated'));
$new_ausgabe = stripslashes($ausgabe);
if ($old_ausgabe != $new_ausgabe) {
// article updaten - nur wenn ausgabe sich veraendert hat
$gc = new rex_sql();
$gc->setQuery("SELECT DISTINCT(" . $REX['TABLE_PREFIX'] . "article.id) FROM " . $REX['TABLE_PREFIX'] . "article\r\n LEFT JOIN " . $REX['TABLE_PREFIX'] . "article_slice ON " . $REX['TABLE_PREFIX'] . "article.id=" . $REX['TABLE_PREFIX'] . "article_slice.article_id\r\n WHERE " . $REX['TABLE_PREFIX'] . "article_slice.modultyp_id='{$modul_id}'");
for ($i = 0; $i < $gc->getRows(); $i++) {
rex_deleteCacheArticle($gc->getValue($REX['TABLE_PREFIX'] . "article.id"));
$gc->next();
}
}
示例11: saveOverLangValues
/**
* @param rex_news_form $form
* @param $id
* @param $clang
*/
public static function saveOverLangValues(rex_news_form $form, $id, $clang)
{
global $REX;
$lang = new rex_sql();
$lang->setQuery('SELECT `id` FROM `' . $REX['TABLE_PREFIX'] . 'clang` WHERE `id` != ' . $clang);
for ($i = 1; $i <= $lang->getRows(); $i++) {
$sql = new rex_sql();
$sql->setTable($form->getTableName());
$sql->setDebug(true);
$sql->setWhere('`id` = ' . $id . ' AND `clang` = ' . $lang->getValue('id'));
$sql->select('id');
$sql->setTable($form->getTableName());
$sql->setDebug(true);
$sql->setWhere('`id` = ' . $id . ' AND `clang` = ' . $lang->getValue('id'));
if (OOAddon::isAvailable('metainfo')) {
$sql->setValues($form->getMetaValues());
}
if ($sql->getRows()) {
$sql->setValues(array_intersect_key($form->getValues(), array_flip($form->getOverSavedFields())));
$sql->setValue('clang', $lang->getValue('id'));
$sql->setValue('id', $id);
$sql->update();
} else {
$sql->setValues($form->getValues());
$sql->setValue('clang', $lang->getValue('id'));
$sql->setValue('id', $id);
$sql->insert();
}
$lang->next();
}
}
示例12: implode
// Allgemeine Funktionen aufrufen bei Listenansicht (Offline stellen etc.)
switch ($func) {
case 'setstatus':
$oid = rex_request('oid', 'int');
$statusfield = rex_request('statusfield', 'string');
$oldstatus = rex_request('oldstatus', 'int');
$minstatus = rex_request('minstatus', 'int', 0);
$maxstatus = rex_request('maxstatus', 'int');
if (setStatus(TBL_NEWS, $oid, $statusfield, $oldstatus, $minstatus, $maxstatus)) {
echo rex_info('Statusupdate erfolgreich');
} else {
echo rex_warning('Statusupdate nicht erfolgreich');
}
$func = '';
break;
case 'delete':
$postparams = implode(",", $_POST['ids']);
$sql = new rex_sql();
$sql->setTable(TBL_NEWS);
$sql->setWhere('id IN (' . $postparams . ')');
$success = $sql->delete();
if ($sql->getRows() > 0) {
echo rex_info('Die Datensätze wurden gelöscht');
} else {
echo rex_warning('Die Datensätze konnten nicht gelöscht werden');
}
$func = '';
break;
}
require $file;
require $REX['INCLUDE_PATH'] . "/layout/bottom.php";
示例13: elseif
<?php
/**
*
* @package redaxo4
* @version svn:$Id$
*/
// *************************************** SUBPAGE: KATEGORIEN
if ($PERMALL) {
$edit_id = rex_request('edit_id', 'int');
if ($media_method == 'edit_file_cat') {
$cat_name = rex_request('cat_name', 'string');
$db = new rex_sql();
$db->setTable($REX['TABLE_PREFIX'] . 'file_category');
$db->setWhere('id=' . $edit_id);
$db->setValue('name', $cat_name);
$db->addGlobalUpdateFields();
if ($db->update()) {
$info = $I18N->msg('pool_kat_updated', $cat_name);
} else {
$warning = $db->getError();
}
} elseif ($media_method == 'delete_file_cat') {
$gf = new rex_sql();
$gf->setQuery('SELECT * FROM ' . $REX['TABLE_PREFIX'] . 'file WHERE category_id=' . $edit_id);
$gd = new rex_sql();
$gd->setQuery('SELECT * FROM ' . $REX['TABLE_PREFIX'] . 'file_category WHERE re_id=' . $edit_id);
if ($gf->getRows() == 0 && $gd->getRows() == 0) {
$gf->setQuery('DELETE FROM ' . $REX['TABLE_PREFIX'] . 'file_category WHERE id=' . $edit_id);
$info = $I18N->msg('pool_kat_deleted');
} else {
示例14: header
header('Location: index.php?page=content&article_id=' . $category_id . '&mode=meta&clang=' . $clang . '&ctype=' . $ctype . '&message=' . urlencode($message));
exit;
} else {
$message = $I18N->msg('content_error_movecategory');
}
} else {
$message = $I18N->msg('no_rights_to_this_function');
}
}
// ------------------------------------------ END: MOVE CATEGORY
// ------------------------------------------ START: SAVE METADATA
if (rex_post('savemeta', 'string')) {
$meta_sql = new rex_sql();
$meta_sql->setTable($REX['TABLE_PREFIX'] . "article");
// $meta_sql->debugsql = 1;
$meta_sql->setWhere("id='{$article_id}' AND clang={$clang}");
$meta_sql->setValue('name', $meta_article_name);
$meta_sql->addGlobalUpdateFields();
if ($meta_sql->update()) {
$article->setQuery("SELECT * FROM " . $REX['TABLE_PREFIX'] . "article WHERE id='{$article_id}' AND clang='{$clang}'");
$message = $I18N->msg("metadata_updated") . $message;
rex_generateArticle($article_id);
// ----- EXTENSION POINT
$message = rex_register_extension_point('ART_META_UPDATED', $message, array('id' => $article_id, 'clang' => $clang, 'name' => $meta_article_name));
} else {
$message .= $meta_sql->getError();
}
}
// ------------------------------------------ END: SAVE METADATA
// ------------------------------------------ START: CONTENT HEAD MENUE
$num_ctypes = count($REX['CTYPE']);
示例15: setTableField
public static function setTableField($table_name, array $table_field)
{
unset($table_field['id']);
if ($table_name == '') {
throw new Exception('table_name must be set');
}
if (count($table_field) == 0) {
throw new Exception('field must be a filled array');
}
$fieldIdentifier = array('type_id' => $table_field['type_id'], 'type_name' => $table_field['type_name'], 'name' => $table_field['name']);
$currentFields = rex_xform_manager_table::get($table_name)->getFields($fieldIdentifier);
// validate specials
if ($table_field['type_id'] == 'validate') {
$table_field['list_hidden'] = 1;
$table_field['search'] = 0;
}
self::createMissingFieldColumns($table_field);
if (count($currentFields) > 1) {
throw new Exception('more than one field found for table: ' . $table_name . ' with Fieldidentifier: ' . implode(', ', $fieldIdentifier) . '');
} elseif (count($currentFields) == 0) {
// Insert
$field_insert = new rex_sql();
$field_insert->debugsql = self::$debug;
$field_insert->setTable(rex_xform_manager_field::table());
$field_insert->setValue('table_name', $table_name);
foreach ($table_field as $field_name => $field_value) {
$field_insert->setValue($field_name, $field_value);
}
if (!isset($table['prio'])) {
$field_insert->setValue('prio', rex_xform_manager_table::get($table_name)->getMaximumPrio() + 1);
}
$field_insert->insert();
} else {
// Update
$currentField = $currentFields[0]->toArray();
foreach ($table_field as $field_name => $field_value) {
$currentField[$field_name] = $field_value;
}
$field_update = new rex_sql();
$field_update->debugsql = self::$debug;
$field_update->setTable(rex_xform_manager_field::table());
$add_where = array();
foreach ($fieldIdentifier as $field => $value) {
$add_where[] = '`' . mysql_real_escape_string($field) . '`="' . mysql_real_escape_string($table_name) . '"';
}
$where = 'table_name="' . mysql_real_escape_string($table_name) . '"';
if (count($add_where) > 0) {
$where .= ' and (' . implode(' and ', $add_where) . ') ';
}
$field_update->setWhere($where);
foreach ($table_field as $field_name => $field_value) {
$field_update->setValue($field_name, $field_value);
}
$field_update->update();
}
}