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


PHP sql::setquery方法代码示例

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


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

示例1: rex_copyContent

/**
 * Kopiert die Inhalte 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 [$from_re_sliceid] Id des Slices, bei dem begonnen werden soll
 */
function rex_copyContent($from_id, $to_id, $from_clang = 0, $to_clang = 0, $from_re_sliceid = 0)
{
    global $REX, $REX_USER;
    if ($from_id == $to_id && $from_clang == $to_clang) {
        return false;
    }
    $gc = new sql();
    $gc->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article_slice where re_article_slice_id='{$from_re_sliceid}' and article_id='{$from_id}' and clang='{$from_clang}'");
    if ($gc->getRows() == 1) {
        // letzt slice_id des ziels holen ..
        $glid = new sql();
        $glid->setQuery("select r1.id, r1.re_article_slice_id\r\n                     from " . $REX['TABLE_PREFIX'] . "article_slice as r1 \r\n                     left join " . $REX['TABLE_PREFIX'] . "article_slice as r2 on r1.id=r2.re_article_slice_id \r\n                     where r1.article_id={$to_id} and r1.clang={$to_clang} and r2.id is NULL;");
        if ($glid->getRows() == 1) {
            $to_last_slice_id = $glid->getValue("r1.id");
        } else {
            $to_last_slice_id = 0;
        }
        $ins = new sql();
        // $ins->debugsql = 1;
        $ins->setTable($REX['TABLE_PREFIX'] . "article_slice");
        $cols = new sql();
        // $cols->debugsql = 1;
        $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 == "clang") {
                $value = $to_clang;
            } elseif ($colname == "re_article_slice_id") {
                $value = $to_last_slice_id;
            } elseif ($colname == "article_id") {
                $value = $to_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 = addslashes($gc->getValue("{$colname}"));
            }
            if ($colname != "id") {
                $ins->setValue($colname, $value);
            }
        }
        $ins->insert();
        // id holen und als re setzen und weitermachen..
        rex_copyContent($from_id, $to_id, $from_clang, $to_clang, $gc->getValue("id"));
        return true;
    }
    rex_generateArticle($to_id);
    return true;
}
开发者ID:BackupTheBerlios,项目名称:redaxo-svn,代码行数:63,代码来源:function_rex_generate.inc.php

示例2: next

                 next($tar->message);
             }
         }
     }
 } elseif ($dbanlegen == 4) {
     // ----- community0.5 anlegen
     $REX[version] = "2.7";
     // ----- db anlegen
     $file_temp = "include/install/community0.5_redaxo2.7.sql";
     $h = fopen($file_temp, "r");
     $conts = fread($h, filesize($file_temp));
     $all = explode("\n", $conts);
     $add = new sql();
     // $add->debugsql = 1;
     foreach ($all as $hier) {
         $add->setquery(Trim(str_replace("||||||+N+||||||", "\n", $hier), ";"));
         $add->flush();
     }
     // ----- dateien anlegen
     $file_temp = $REX[INCLUDE_PATH] . "/install/community0.5_redaxo2.7.tar.gz";
     $tar = new tar();
     $tar->openTAR($file_temp);
     if (!$tar->extractTar()) {
         $err_msg = $I18N->msg("problem_when_extracting") . "<br>";
         if (count($tar->message) > 0) {
             $err_msg .= $I18N->msg("create_dirs_manually") . "<br>";
             reset($tar->message);
             for ($fol = 0; $fol < count($tar->message); $fol++) {
                 $err_msg .= key($tar->message) . "<br>";
                 next($tar->message);
             }
开发者ID:BackupTheBerlios,项目名称:redaxo-svn,代码行数:31,代码来源:setup.php

示例3: KEY

 }
 if (count($key) > 0) {
     $query .= ", PRIMARY KEY(";
     for ($k = 0, reset($key); $k < count($key); $k++, next($key)) {
         // <-- yeah super for schleife, rock 'em hard :)
         $query .= current($key);
         if ($k + 1 != count($key)) {
             $query .= ",";
         }
     }
     $query .= ")";
 }
 $query .= ")TYPE=MyISAM;";
 $dump .= $query . "\n";
 $cont = new sql();
 $cont->setquery("SELECT * FROM " . $tabs->getvalue("Tables_in_" . $DB[1][NAME]));
 for ($j = 0; $j < $cont->rows; $j++, $cont->next()) {
     $query = "INSERT INTO " . $tabs->getvalue("Tables_in_" . $DB[1][NAME]) . " VALUES (";
     $cols->counter = 0;
     for ($k = 0; $k < $cols->rows; $k++, $cols->next()) {
         if (is_numeric($cont->getvalue($cols->getvalue("Field")))) {
             $query .= "'" . $cont->getvalue($cols->getvalue("Field")) . "'";
         } else {
             $query .= "'" . addslashes($cont->getvalue($cols->getvalue("Field"))) . "'";
         }
         if ($k + 1 != $cols->rows) {
             $query .= ",";
         }
     }
     $query .= ");";
     $dump .= str_replace("\n", "||||||+N+||||||", $query) . "\n";
开发者ID:BackupTheBerlios,项目名称:redaxo-svn,代码行数:31,代码来源:export.inc.php

示例4: KEY

 }
 if (count($key) > 0) {
     $query .= ", PRIMARY KEY(";
     for ($k = 0, reset($key); $k < count($key); $k++, next($key)) {
         // <-- yeah super for schleife, rock 'em hard :)
         $query .= current($key);
         if ($k + 1 != count($key)) {
             $query .= ",";
         }
     }
     $query .= ")";
 }
 $query .= ")TYPE=MyISAM;";
 $dump .= $query . "\n";
 $cont = new sql();
 $cont->setquery("SELECT * FROM " . $tab);
 for ($j = 0; $j < $cont->rows; $j++, $cont->next()) {
     $query = "INSERT INTO " . $tab . " VALUES (";
     $cols->counter = 0;
     for ($k = 0; $k < $cols->rows; $k++, $cols->next()) {
         $con = $cont->getvalue($cols->getvalue("Field"));
         if (is_numeric($con)) {
             $query .= "'" . $con . "'";
         } else {
             $query .= "'" . addslashes($con) . "'";
         }
         if ($k + 1 != $cols->rows) {
             $query .= ",";
         }
     }
     $query .= ");";
开发者ID:BackupTheBerlios,项目名称:redaxo-svn,代码行数:31,代码来源:index.inc.php

示例5: rex_a1_export_db

/**
 * Erstellt einen SQL Dump, der die aktuellen Datebankstruktur darstellt
 * @return string SQL Dump der Datenbank
 */
function rex_a1_export_db()
{
    global $REX;
    $tabs = new sql();
    $tabs->setquery("SHOW TABLES");
    $dump = '';
    for ($i = 0; $i < $tabs->rows; $i++, $tabs->next()) {
        $tab = $tabs->getValue("Tables_in_" . $REX['DB']['1']['NAME']);
        if (strstr($tab, $REX['TABLE_PREFIX']) == $tab && $tab != $REX['TABLE_PREFIX'] . 'user') {
            $cols = new sql();
            $cols->setquery("SHOW COLUMNS FROM " . $tab);
            $query = "DROP TABLE IF EXISTS " . $tab . ";\nCREATE TABLE " . $tab . " (";
            $key = array();
            // Spalten auswerten
            for ($j = 0; $j < $cols->rows; $j++, $cols->next()) {
                $colname = $cols->getValue("Field");
                $coltype = $cols->getValue("Type");
                // Null Werte
                if ($cols->getValue("Null") == 'YES') {
                    $colnull = "NULL";
                } else {
                    $colnull = "NOT NULL";
                }
                // Default Werte
                if ($cols->getValue("Default") != '') {
                    $coldef = "DEFAULT " . $cols->getValue("Default") . " ";
                } else {
                    $coldef = "";
                }
                // Spezial Werte
                $colextra = $cols->getValue("Extra");
                if ($cols->getValue("Key") != '') {
                    $key[] = $colname;
                    $colnull = "NOT NULL";
                }
                $query .= " {$colname} {$coltype} {$colnull} {$coldef} {$colextra}";
                if ($j + 1 != $cols->rows) {
                    $query .= ",";
                }
            }
            // Primärschlüssel Auswerten
            if (count($key) > 0) {
                $query .= ", PRIMARY KEY(";
                for ($k = 0, reset($key); $k < count($key); $k++, next($key)) {
                    // <-- yeah super for schleife, rock 'em hard :)
                    $query .= current($key);
                    if ($k + 1 != count($key)) {
                        $query .= ",";
                    }
                }
                $query .= ")";
            }
            $query .= ")TYPE=MyISAM;";
            $dump .= $query . "\n";
            // Inhalte der Tabelle Auswerten
            $cont = new sql();
            $cont->setquery("SELECT * FROM " . $tab);
            for ($j = 0; $j < $cont->rows; $j++, $cont->next()) {
                $query = "INSERT INTO " . $tab . " VALUES (";
                $cols->counter = 0;
                for ($k = 0; $k < $cols->rows; $k++, $cols->next()) {
                    $con = $cont->getValue($cols->getValue("Field"));
                    if (is_numeric($con)) {
                        $query .= "'" . $con . "'";
                    } else {
                        $query .= "'" . addslashes($con) . "'";
                    }
                    if ($k + 1 != $cols->rows) {
                        $query .= ",";
                    }
                }
                $query .= ");";
                $dump .= str_replace(array("\r\n", "\n"), '\\r\\n', $query) . "\n";
            }
        }
    }
    // Versionsstempel hinzufügen
    $dump = str_replace("\r", "", $dump);
    $header = "## Redaxo Database Dump Version " . $REX['VERSION'] . "\n";
    $header .= "## Prefix " . $REX['TABLE_PREFIX'] . "\n";
    return $header . $dump;
}
开发者ID:BackupTheBerlios,项目名称:redaxo-svn,代码行数:86,代码来源:function_import_export.inc.php


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