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


PHP rex_sql::escape方法代码示例

本文整理汇总了PHP中rex_sql::escape方法的典型用法代码示例。如果您正苦于以下问题:PHP rex_sql::escape方法的具体用法?PHP rex_sql::escape怎么用?PHP rex_sql::escape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rex_sql的用法示例。


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

示例1: elseif

 function rex_copyRevisionContent($article_id, $clang, $from_revision_id, $to_revision_id, $from_re_sliceid = 0, $to_revision_delete = FALSE)
 {
     global $REX;
     if ($to_revision_delete) {
         $dc = new rex_sql();
         // $dc->debugsql = 1;
         $dc->setQuery('delete from ' . $REX['TABLE_PREFIX'] . 'article_slice where article_id=' . $article_id . ' and clang=' . $clang . ' and revision=' . $to_revision_id);
     }
     if ($from_revision_id == $to_revision_id) {
         return false;
     }
     $gc = new rex_sql();
     // $gc->debugsql = 1;
     $gc->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article_slice where re_article_slice_id='{$from_re_sliceid}' and article_id='{$article_id}' and clang='{$clang}' and revision='{$from_revision_id}'");
     if ($gc->getRows() == 1) {
         // letzt slice_id des ziels holen ..
         $glid = new rex_sql();
         // $glid->debugsql = 1;
         $glid->setQuery("\n\t\t\t\t\tselect \n\t\t\t\t\t\tr1.id, r1.re_article_slice_id\n\t        from \n\t\t\t\t\t\t" . $REX['TABLE_PREFIX'] . "article_slice as r1\n\t\t\t\t\tleft join " . $REX['TABLE_PREFIX'] . "article_slice as r2 on r1.id = r2.re_article_slice_id\n\t        where \n\t\t\t\t\t\tr1.article_id = {$article_id} and r1.clang = {$clang} and \n\t\t\t\t\t\tr2.id is NULL and \n\t\t\t\t\t\tr1.revision='{$to_revision_id}';");
         if ($glid->getRows() == 1) {
             $to_last_slice_id = $glid->getValue("r1.id");
         } else {
             $to_last_slice_id = 0;
         }
         $ins = new rex_sql();
         // $ins->debugsql = 1;
         $ins->setTable($REX['TABLE_PREFIX'] . "article_slice");
         $cols = new rex_sql();
         $cols->setquery("SHOW COLUMNS FROM " . $REX['TABLE_PREFIX'] . "article_slice");
         for ($j = 0; $j < $cols->rows; $j++, $cols->next()) {
             $colname = $cols->getValue("Field");
             if ($colname == "re_article_slice_id") {
                 $value = $to_last_slice_id;
             } elseif ($colname == "revision") {
                 $value = $to_revision_id;
             } elseif ($colname == "createdate") {
                 $value = time();
             } elseif ($colname == "updatedate") {
                 $value = time();
             } elseif ($colname == "createuser") {
                 $value = $REX["USER"]->getValue("login");
             } elseif ($colname == "updateuser") {
                 $value = $REX["USER"]->getValue("login");
             } else {
                 $value = $gc->getValue($colname);
             }
             if ($colname != "id") {
                 $ins->setValue($colname, $ins->escape($value));
             }
         }
         $ins->insert();
         // id holen und als re setzen und weitermachen..
         rex_copyRevisionContent($article_id, $clang, $from_revision_id, $to_revision_id, $gc->getValue("id"));
         return true;
     }
     rex_generateArticle($article_id);
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:redaxo-svn,代码行数:58,代码来源:function_rex_copyrevisioncontent.inc.php

示例2: search

 /** 
  * Executes the search.
  * 
  * @param string $_search
  * 
  * @return array
  */
 function search($_search)
 {
     $startTime = microtime(true);
     $this->searchString = trim(stripslashes($_search));
     $keywordCount = $this->parseSearchString($this->searchString);
     if (empty($this->searchString) or empty($this->searchArray)) {
         return array('count' => 0, 'hits' => array(), 'keywords' => array(), 'keywords' => '', 'sql' => 'No search performed.', 'blacklisted' => false, 'hash' => '', 'simwordsnewsearch' => '', 'simwords' => array(), 'time' => 0);
     }
     // ask cache
     if ($this->cache and $this->isCached($this->searchString)) {
         $this->cachedArray['time'] = microtime(true) - $startTime;
         if ($this->similarwords and $this->cachedArray['count'] > 0) {
             $this->storeKeywords($this->searchArray);
         }
         // EP registrieren
         rex_register_extension_point('A587_SEARCH_EXECUTED', $this->cachedArray);
         //var_dump($this->cachedArray['sql']);
         return $this->cachedArray;
     }
     $return = array();
     $return['simwordsnewsearch'] = '';
     $return['simwords'] = array();
     if ($this->similarwords) {
         $simwords = array();
         foreach ($this->searchArray as $keyword) {
             $sounds = array();
             if ($this->similarwordsMode & A587_SIMILARWORDS_SOUNDEX) {
                 $sounds[] = "soundex = '" . soundex($keyword['search']) . "'";
             }
             if ($this->similarwordsMode & A587_SIMILARWORDS_METAPHONE) {
                 $sounds[] = "metaphone = '" . metaphone($keyword['search']) . "'";
             }
             if ($this->similarwordsMode & A587_SIMILARWORDS_COLOGNEPHONE) {
                 $sounds[] = "colognephone = '" . $this->cologne_phone($keyword['search']) . "'";
             }
             $simwords[] = sprintf("\n          SELECT\n            GROUP_CONCAT(DISTINCT keyword SEPARATOR ' ') as keyword,\n            '%s' AS typedin,\n            SUM(count) as count\n          FROM `%s`\n          WHERE 1\n            %s\n            AND (%s)", $keyword['search'], $this->tablePrefix . '587_keywords', $this->clang !== false ? 'AND (clang = ' . intval($this->clang) . ' OR clang IS NULL)' : '', implode(' OR ', $sounds));
         }
         // simwords
         $simWordsSQL = new rex_sql();
         foreach ($simWordsSQL->getArray(sprintf("\n        %s\n        GROUP BY %s\n        ORDER BY SUM(count)", implode(' UNION ', $simwords), $this->similarwordsPermanent ? "''" : 'keyword, typedin')) as $simword) {
             $return['simwords'][$simword['typedin']] = array('keyword' => $simword['keyword'], 'typedin' => $simword['typedin'], 'count' => $simword['count']);
         }
         $newsearch = array();
         foreach ($this->searchArray as $keyword) {
             if (preg_match($this->encodeRegex('~\\s~is'), $keyword['search'])) {
                 $quotes = '"';
             } else {
                 $quotes = '';
             }
             if (array_key_exists($keyword['search'], $return['simwords'])) {
                 $newsearch[] = $quotes . $return['simwords'][$keyword['search']]['keyword'] . $quotes;
             } else {
                 $newsearch[] = $quotes . $keyword['search'] . $quotes;
             }
         }
         $return['simwordsnewsearch'] = implode(' ', $newsearch);
     }
     if ($this->similarwordsPermanent) {
         $keywordCount = $this->parseSearchString($this->searchString . ' ' . $return['simwordsnewsearch']);
     }
     $searchColumns = array();
     switch ($this->textMode) {
         case 'unmodified':
             $searchColumns[] = 'unchangedtext';
             break;
         case 'both':
             $searchColumns[] = 'plaintext';
             $searchColumns[] = 'unchangedtext';
             break;
         default:
             $searchColumns[] = 'plaintext';
     }
     $sql = new rex_sql();
     $Awhere = array();
     $Amatch = array();
     foreach ($this->searchArray as $keyword) {
         // build MATCH-Array
         $match = sprintf("(( MATCH (`%s`) AGAINST ('%s')) * %d)", implode('`,`', $searchColumns), $sql->escape($keyword['search']), $keyword['weight']);
         if ($this->searchEntities) {
             $match .= ' + ' . sprintf("(( MATCH (`%s`) AGAINST ('%s')) * %d)", implode('`,`', $searchColumns), $sql->escape(htmlentities($keyword['search'], ENT_COMPAT, 'UTF-8')), $keyword['weight']);
         }
         $Amatch[] = $match;
         // build WHERE-Array
         if ($this->searchMode == 'match') {
             $AWhere[] = $match;
         } else {
             $tmpWhere = array();
             foreach ($searchColumns as $searchColumn) {
                 $tmpWhere[] = sprintf("(`%s` LIKE '%%%s%%')", $searchColumn, str_replace(array('%', '_'), array('\\%', '\\_'), $sql->escape($keyword['search'])));
                 if ($this->searchEntities) {
                     $tmpWhere[] = sprintf("(`%s` LIKE '%%%s%%')", $searchColumn, str_replace(array('%', '_'), array('\\%', '\\_'), $sql->escape(htmlentities($keyword['search'], ENT_COMPAT, 'UTF-8'))));
                 }
             }
//.........这里部分代码省略.........
开发者ID:olien,项目名称:rexsearch,代码行数:101,代码来源:class.rexsearch.inc.php

示例3: foreach

if (!empty($_GET['do']) and $_GET['do'] == 'incremental') {
    echo '<div class="rex-message" style="display:none;" id="rexsearch_generate_cancel"><div class="rex-warning"><p><span>' . $I18N->Msg('a587_settings_generate_cancel') . '</span></p></div></div>';
    echo '<div class="rex-message" style="display:none;" id="rexsearch_generate_done"><div class="rex-info"><p><span>' . $I18N->Msg('a587_settings_generate_done') . '</span></p></div></div>';
    echo '<div class="rex-message" id="rexsearch_generate_inprogress"><div class="rex-warning" style="background-image:url(../files/addons/rexsearch/loading.gif)"><p><span>' . $I18N->Msg('a587_settings_generate_inprogress') . '</span></p></div></div>';
    echo '<h4 class="rex-hl3" id="rexsearch_generate_header">' . $I18N->Msg('a587_settings_generate_incremental') . '</h4>';
    $js_output = '';
    $globalcount = 0;
    foreach (a587_getArticleIds() as $id) {
        #$js_output .= 'index("art",'.$id.');';
        $js_output .= 'indexArray.push(new Array("art",' . $id . '));';
        $globalcount++;
    }
    if (!empty($REX['ADDON']['settings']['rexsearch']['include']) and is_array($REX['ADDON']['settings']['rexsearch']['include'])) {
        foreach ($REX['ADDON']['settings']['rexsearch']['include'] as $table => $columnArray) {
            $sql = new rex_sql();
            $sql->setQuery("SELECT COUNT(*) AS count FROM `" . $sql->escape($table) . "`");
            $count = intval($sql->getValue('count'));
            $step_width = 100;
            for ($i = 0; $i < $count; $i += $step_width) {
                foreach ($columnArray as $column) {
                    #$js_output .= 'index("col",new Array("'.$table.'","'.$column.'"));';
                    $js_output .= 'indexArray.push(new Array("col",new Array("' . $table . '","' . $column . '",' . $i . ',' . $step_width . ')));';
                    $globalcount++;
                }
            }
        }
    }
    if (!empty($REX['ADDON']['settings']['rexsearch']['indexmediapool']) and intval($REX['ADDON']['settings']['rexsearch']['indexmediapool'])) {
        $mediaSQL = new rex_sql();
        $mediaSQL->setTable($REX['TABLE_PREFIX'] . 'file');
        if ($mediaSQL->select('file_id, category_id, filename')) {
开发者ID:olien,项目名称:rexsearch,代码行数:31,代码来源:generate.inc.php

示例4: rex_addCLang

/**
 * Erstellt eine Clang
 *
 * @param $id   Id der Clang
 * @param $name Name der Clang
 * 
 * @return TRUE bei Erfolg, sonst FALSE
 */
function rex_addCLang($id, $name)
{
    global $REX;
    if (isset($REX['CLANG'][$id])) {
        return FALSE;
    }
    $REX['CLANG'][$id] = $name;
    $file = $REX['INCLUDE_PATH'] . "/clang.inc.php";
    rex_replace_dynamic_contents($file, "\$REX['CLANG'] = " . var_export($REX['CLANG'], TRUE) . ";\n");
    $add = new rex_sql();
    $add->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article where clang='0'");
    $fields = $add->getFieldnames();
    $adda = new rex_sql();
    // $adda->debugsql = 1;
    for ($i = 0; $i < $add->getRows(); $i++) {
        $adda->setTable($REX['TABLE_PREFIX'] . "article");
        foreach ($fields as $key => $value) {
            if ($value == 'pid') {
                echo '';
            } else {
                if ($value == 'clang') {
                    $adda->setValue('clang', $id);
                } else {
                    if ($value == 'status') {
                        $adda->setValue('status', '0');
                    } else {
                        $adda->setValue($value, $add->escape($add->getValue($value)));
                    }
                }
            }
        }
        $adda->insert();
        $add->next();
    }
    $add = new rex_sql();
    $add->setQuery("insert into " . $REX['TABLE_PREFIX'] . "clang set id='{$id}',name='{$name}'");
    // ----- EXTENSION POINT
    rex_register_extension_point('CLANG_ADDED', '', array('id' => $id, 'name' => $name));
    return TRUE;
}
开发者ID:BackupTheBerlios,项目名称:redaxo-svn,代码行数:48,代码来源:function_rex_generate.inc.php

示例5: rex_moveArticle

/**
 * Verschieben eines Artikels von einer Kategorie in eine Andere
 *
 * @param int $id          ArtikelId des zu verschiebenden Artikels
 * @param int $from_cat_id KategorieId des Artikels, der Verschoben wird
 * @param int $to_cat_id   KategorieId in die der Artikel verschoben werden soll
 * 
 * @return boolean TRUE bei Erfolg, sonst FALSE
 */
function rex_moveArticle($id, $from_cat_id, $to_cat_id)
{
    global $REX;
    $id = (int) $id;
    $to_cat_id = (int) $to_cat_id;
    $from_cat_id = (int) $from_cat_id;
    if ($from_cat_id == $to_cat_id) {
        return false;
    }
    // Artikel in jeder Sprache verschieben
    foreach ($REX['CLANG'] as $clang => $clang_name) {
        // validierung der id & from_cat_id
        $from_sql = new rex_sql();
        $from_sql->setQuery('select * from ' . $REX['TABLE_PREFIX'] . 'article where clang="' . $clang . '" and startpage<>1 and id="' . $id . '" and re_id="' . $from_cat_id . '"');
        if ($from_sql->getRows() == 1) {
            // validierung der to_cat_id
            $to_sql = new rex_sql();
            $to_sql->setQuery('select * from ' . $REX['TABLE_PREFIX'] . 'article where clang="' . $clang . '" and startpage=1 and id="' . $to_cat_id . '"');
            if ($to_sql->getRows() == 1 || $to_cat_id == 0) {
                if ($to_sql->getRows() == 1) {
                    $re_id = $to_sql->getValue('id');
                    $path = $to_sql->getValue('path') . $to_sql->getValue('id') . '|';
                    $catname = $to_sql->getValue('name');
                } else {
                    // In RootEbene
                    $re_id = 0;
                    $path = '|';
                    $catname = $from_sql->getValue('name');
                }
                $art_sql = new rex_sql();
                //$art_sql->debugsql = 1;
                $art_sql->setTable($REX['TABLE_PREFIX'] . 'article');
                $art_sql->setValue('re_id', $re_id);
                $art_sql->setValue('path', $path);
                $art_sql->setValue('catname', $art_sql->escape($catname));
                // Artikel als letzten Artikel in die neue Kat einfügen
                $art_sql->setValue('prior', '99999');
                // Kopierter Artikel offline setzen
                $art_sql->setValue('status', '0');
                $art_sql->addGlobalUpdateFields();
                $art_sql->setWhere('clang="' . $clang . '" and startpage<>1 and id="' . $id . '" and re_id="' . $from_cat_id . '"');
                $art_sql->update();
                // Prios neu berechnen
                rex_newArtPrio($to_cat_id, $clang, 1, 0);
                rex_newArtPrio($from_cat_id, $clang, 1, 0);
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
    // Caches des Artikels löschen, in allen Sprachen
    rex_deleteCacheArticle($id);
    // Caches der Kategorien löschen, da sich derin befindliche Artikel geändert haben
    rex_deleteCacheArticle($from_cat_id);
    rex_deleteCacheArticle($to_cat_id);
    return true;
}
开发者ID:BackupTheBerlios,项目名称:redaxo-svn,代码行数:68,代码来源:function_rex_content.inc.php


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