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


PHP SQL::CreateUpdate方法代码示例

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


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

示例1: votedown

 public static function votedown($data)
 {
     $out = array();
     if (!MyUser::isloggedin()) {
         throw new APIException("User ist nicht angemeldet.", 100);
     }
     if (MyUser::getKarmaPoints() < 100) {
         throw new APIException("Du benötigst 100 Karma-Punkte um einen negativen Vote zu geben.", 200);
     }
     if (!isset($data["question"])) {
         throw new APIException("Benötigter Parameter fehlt (question).", 50);
     }
     $db = new SQL(0);
     $row = $db->cmdrow(0, 'SELECT * FROM questions WHERE id={0}', array($data["question"] + 0));
     if (!isset($row["id"])) {
         throw new APIException("Diese Frage existiert nicht (mehr)", 300);
     }
     if ($row["author"] == MyUser::id()) {
         throw new APIException("Sie dürfen nicht auf Ihre eigene Frage voten", 301);
     }
     $raw = $db->cmdrow(0, 'SELECT * FROM question_votes WHERE question={0} AND user={1} LIMIT 0,1', array($data["question"] + 0, MyUser::id()));
     $w = array();
     $w["question"] = $data["question"] + 0;
     $w["user"] = MyUser::id();
     $w["vote"] = -1;
     $db->CreateUpdate(0, "question_votes", $w);
     $db->cmd(0, 'UPDATE questions as T1 SET count_votes = (SELECT sum(vote) FROM question_votes WHERE question=T1.id) WHERE id={0} LIMIT 1', false, array($w["question"]));
     $out["sumvotes"] = self::getVotes(array("question" => $w["question"]));
     if (!isset($raw["id"])) {
         Karma::RuleAction("VOTEDOWN_QUESTION", array("user" => $row["author"], "question" => $w["question"]));
     }
     Badge::add(9, MyUser::id(), array("question" => $w["question"]));
     //Kritiker: für downvote
     return $out;
 }
开发者ID:andreaskasper,项目名称:askbot_php,代码行数:35,代码来源:question.php

示例2: add

 */
class Badges
{
    public static $badgelist = array(1 => array("title" => "Autobiograph", "medal" => 3, "desc" => "Hat sein Benutzerprofil vervollständigt", "key" => "b%b_u%u"), 2 => array("title" => "Bürgerpolizist", "medal" => 3, "desc" => "Hat einen Beitrag gemeldet", "key" => "b%b_u%u"), 3 => array("title" => "Schreiberling", "medal" => 3, "desc" => "Hat die erste Frage gestellt", "key" => "b%b_u%u"), 4 => array("title" => "Helfer", "medal" => 3, "desc" => "Hat die erste Antwort geschrieben", "key" => "b%b_u%u"), 5 => array("title" => "Blabberer", "medal" => 3, "desc" => "Hat die erste Kommentar geschrieben", "key" => "b%b_u%u"), 6 => array("title" => "Callboy", "medal" => 3, "desc" => "Hilft Usern auch über Skype", "key" => "b%b_u%u"), 9 => array("title" => "Kritiker", "medal" => 3, "desc" => "Bewertete einen Beitrag negativ / downvote", "key" => "b%b_u%u"), 10 => array("title" => "Redakteur", "medal" => 3, "desc" => "Editiere einen Beitrag", "key" => "b%b_u%u"), 21 => array("title" => "Elementare Frage", "medal" => 1, "desc" => "Stellte eine Frage mit mindestens 500 Views", "key" => "b%b_u%u_q%q"), 24 => array("title" => "Gute Frage", "medal" => 2, "desc" => "Frage wurde mindestens 3mal positiv bewertet / upvoted", "key" => "b%b_u%u_q%q"), 31 => array("title" => "Wichtige Frage", "medal" => 2, "desc" => "Stellte eine Frage mit mindestens 250 Views", "key" => "b%b_u%u_q%q"), 41 => array("title" => "Populäre Frage", "medal" => 3, "desc" => "Stellte eine Frage mit mindestens 150 Views", "key" => "b%b_u%u_q%q"), 51 => array("title" => "Tolle Antwort", "medal" => 3, "desc" => "Antwort wurde 3mal positiv bewertet / upvoted", "key" => "b%b_u%u_a%a"), 52 => array("title" => "Gute Antwort", "medal" => 2, "desc" => "Antwort wurde 10mal positiv bewertet / upvoted", "key" => "b%b_u%u_a%a"), 53 => array("title" => "Großartige Antwort", "medal" => 1, "desc" => "Antwort wurde 25mal positiv bewertet / upvoted", "key" => "b%b_u%u_a%a"));
    public static function add($badge, $user = null, $data = array())
    {
        if ($user == null) {
            $user = MyUser::id();
        }
        if (!isset(self::$badgelist[$badge + 0])) {
            throw new Exception("Badge existiert nicht! (" . ($badge + 0) . ")");
        }
        $binfo = self::$badgelist[$badge + 0];
        $db = new SQL(0);
        $w = array();
        $w["keyID"] = $binfo["key"];
        $w["keyID"] = str_replace(array("%b", "%u", "%q", "%a"), array($badge + 0, $user + 0, isset($data["question"]) ? $data["question"] : 0, isset($data["answer"]) ? $data["answer"] : 0), $w["keyID"]);
        $w["user"] = $user + 0;
        $w["badge"] = $badge + 0;
        $w["medal"] = $binfo["medal"];
        $w["dt_received"] = time();
        if (isset($data["question"])) {
            $w["question"] = $data["question"] + 0;
        }
        $db->CreateUpdate(0, 'user_badges', $w);
        switch ($w["medal"]) {
            case 1:
                $db->cmd(0, 'UPDATE LOW_PRIORITY IGNORE user_list as T1 SET award_gold = (SELECT count(*) FROM user_badges WHERE user= T1.id AND medal=1) WHERE id={0} LIMIT 1', true, array($w["user"]));
                break;
            case 2:
                $db->cmd(0, 'UPDATE LOW_PRIORITY IGNORE user_list as T1 SET award_silver = (SELECT count(*) FROM user_badges WHERE user= T1.id AND medal=2) WHERE id={0} LIMIT 1', true, array($w["user"]));
                break;
            case 3:
                $db->cmd(0, 'UPDATE LOW_PRIORITY IGNORE user_list as T1 SET award_bronce = (SELECT count(*) FROM user_badges WHERE user= T1.id AND medal=3) WHERE id={0} LIMIT 1', true, array($w["user"]));
开发者ID:andreaskasper,项目名称:askbot_php,代码行数:34,代码来源:Badges.php

示例3: add

 public static function add($user, $msgid, $points = 0, $question = null)
 {
     $db = new SQL(0);
     $w = array();
     $w["user"] = $user;
     $w["msgid"] = $msgid;
     $w["points"] = $points;
     if ($question != null) {
         $w["question"] = $question;
     }
     $w["created"] = time();
     $db->CreateUpdate(0, "karma_log", $w);
     $db->cmd(0, 'UPDATE user_list SET karma = (SELECT sum(points) FROM karma_log WHERE user = user_list.id) WHERE id={0} LIMIT 1', true, array($user));
     return true;
 }
开发者ID:andreaskasper,项目名称:askbot_php,代码行数:15,代码来源:Karma.php

示例4: UsernameAlreadyInUse

    $w["location"] = $_POST["location"];
    $w["country"] = $_POST["country"];
    $w["language"] = $_POST["language"];
    $w["FlattrUID"] = trim($_POST["FlattrUID"]);
    $w["SkypeID"] = trim($_POST["SkypeID"]);
    $w["GooglePlus"] = trim($_POST["GooglePlus"]);
    $w["PayPal_email"] = $_POST["PayPal_email"];
    $w["show_country"] = (isset($_POST["show_country"]) and $_POST["show_country"] == "1" ? 1 : 0);
    $d = $_POST["birthday_year"] . "-" . $_POST["birthday_month"] . "-" . $_POST["birthday_day"];
    if (!preg_match("`^[0-9\\?]{4}-[0-9\\?]{2}-[0-9\\?]{2}\$`", $d)) {
        PageEngine::AddErrorMessage("save", "Ungültiges Geburtsdatum");
    } else {
        $w["birthday"] = $d;
    }
    $w["biography"] = $_POST["text"];
    $db = new SQL(0);
    $db->CreateUpdate(0, "user_list", $w);
    if ($w["username"] != "" and $w["prename"] != "" and $w["familyname"] != "" and $w["location"] != "" and $w["country"] != "" and $w["language"] != "" and $w["birthday"] != "" and $w["biography"] != "") {
        Badges::add(1, $w["id"]);
    }
    if ($w["SkypeID"] . "" != "") {
        Badges::add(6, $w["id"], array("skype" => $w["SkypeID"]));
    }
    PageEngine::AddSuccessMessage("save", "Profil gespeichert");
}
function UsernameAlreadyInUse($name, $myuserid = 0)
{
    $db = new SQL(0);
    $row = $db->cmdrow(0, 'SELECT id FROM user_list WHERE username = "{0}" AND id != {1} LIMIT 0,1', array($name, $myuserid + 0));
    return isset($row["id"]);
}
开发者ID:andreaskasper,项目名称:askbot_php,代码行数:31,代码来源:userprofile_edit.php

示例5: explode

     $w["author"] = MyUser::id();
 }
 $db->Create(0, 'questions', $w);
 $frageid = $db->LastInsertKey();
 if (!isset($_GET["tag"])) {
     $_GET["tag"] = "";
 }
 $g = explode(",", $_GET["tag"] . "," . $_POST["tags"]);
 foreach (tags2array($_POST["tags"]) as $a) {
     if (trim($a) == "") {
         continue;
     }
     $w3 = array();
     $w3["question"] = $frageid;
     $w3["tag"] = $a;
     $db->CreateUpdate(0, "question_tags", $w3);
 }
 $_SESSION["myuser"]["lastwritten"]["question"][$frageid] = true;
 Karma::RuleAction("CREATE_QUESTION", array("user" => MyUser::id(), "question" => $frageid));
 Badges::add(3, MyUser::id(), array("question" => $frageid));
 //Erste Frage geschrieben
 @file_get_contents("www.google.com/webmasters/tools/ping?sitemap=" . urlencode(SiteConfig::val("baseurl") . "sitemap.xml"));
 $m = SiteConfig::get(0);
 if ($m["twitter"]["consumer"]["secret"] . "" != "" && $m["twitter"]["access"]["secret"] . "" != "") {
     try {
         $twitter = new Twitter($m["twitter"]["consumer"]["key"], $m["twitter"]["consumer"]["secret"]);
         $twitter->setOAuthToken($m["twitter"]["access"]["key"]);
         $twitter->setOAuthTokenSecret($m["twitter"]["access"]["secret"]);
         $url = API_urlshortener::add(Question::PermalinkByData($w3["question"], $w["title"]));
         if (strlen($w["title"]) > 100) {
             $tweet = substr($w["title"], 0, 100) . "... " . $url . " #wikihelp";
开发者ID:andreaskasper,项目名称:askbot_php,代码行数:31,代码来源:ask.php

示例6: changePassword

 public static function changePassword($pwd)
 {
     $db = new SQL(0);
     $w = array();
     $w["username"] = "User[" . self::id() . "]";
     $w["pwd"] = md5($pwd);
     $w["provider"] = "local";
     $w["user"] = MyUser::id();
     $db->CreateUpdate(0, "user_login", $w);
     return true;
 }
开发者ID:andreaskasper,项目名称:askbot_php,代码行数:11,代码来源:MyUser.php

示例7: catch

                } else {
                    $w["isSPAM"] = -2;
                }
            } catch (Exception $ex) {
            }
        }
        $db->CreateUpdate(0, 'answers', $w);
        $answerID = $db->LastInsertKey();
        $db->cmd(0, 'UPDATE questions SET date_action={1},user_action="{2}", count_answers = (SELECT count(*) FROM answers WHERE question=questions.id) WHERE id={0} LIMIT 1', true, array($w["question"], time(), MyUser::id() + 0));
        $_SESSION["myuser"]["lastwritten"]["answers"][$answerID] = true;
        Karma::RuleAction("CREATE_ANSWER", array("user" => MyUser::id(), "question" => $w["question"], "answer" => $answerID));
        Badges::add(4, MyUser::id(), array("question" => $w["question"]));
        //Erste Antwort geschrieben
    }
}
if (isset($_POST["act"]) and $_POST["act"] == "addComment") {
    if (strlen($_POST["comment"]) >= 10 and MyUser::isloggedin()) {
        $w = array();
        $db = new SQL(0);
        $w["question"] = $_POST["question"] + 0;
        $w["answer"] = $_POST["answer"] + 0;
        $w["text"] = $_POST["comment"];
        $w["created"] = time();
        $w["user"] = MyUser::id();
        $db->CreateUpdate(0, 'comments', $w);
        $a = $db->LastInsertKey();
        Badges::add(5, MyUser::id(), array("question" => $w["question"]));
        //Erster Kommentar geschrieben
        @header("Location: #comment-" . $a);
    }
}
开发者ID:andreaskasper,项目名称:askbot_php,代码行数:31,代码来源:question.php

示例8: SQL

<?php

if (isset($_POST["action"]) and $_POST["action"] == "save") {
    $db = new SQL(0);
    $info = $db->cmdrow(0, 'SELECT * FROM questions WHERE id={0} LIMIT 0,1', array($params["id"] + 0));
    if ($info["author"] != MyUser::id()) {
        die("Dies ist nicht Ihre Frage.");
    }
    $w = array();
    $w["keyid"] = $info["id"];
    $w["type"] = "q";
    $w["title"] = $info["title"];
    $w["text"] = $info["question"];
    $w["user"] = MyUser::id();
    $w["dt_created"] = time();
    $db->CreateUpdate(0, 'qatext_versions', $w);
    $w2 = array();
    $w2["id"] = $info["id"];
    $w2["title"] = $_POST["title"];
    $w2["question"] = $_POST["text"];
    $w2["author"] = MyUser::id();
    $w2["tags"] = implode(",", tags2array($_POST["tags"]));
    $w2["date_edited"] = time();
    $w2["date_action"] = time();
    $w2["user_action"] = MyUser::id() + 0;
    $db->CreateUpdate(0, 'questions', $w2);
    $db->cmd(0, 'DELETE FROM `question_tags` WHERE question={0}', true, array($info["id"]));
    foreach (tags2array($_POST["tags"]) as $a) {
        $w3 = array();
        $w3["question"] = $info["id"];
        $w3["tag"] = $a;
开发者ID:andreaskasper,项目名称:askbot_php,代码行数:31,代码来源:question_edit.php

示例9: SQL

<?php

if (isset($_POST["act"]) and $_POST["act"] == "save") {
    $db = new SQL(0);
    $db->cmd(0, 'DELETE FROM user_rights WHERE user={0}', true, array($params["user_id"] + 0));
    foreach ($_POST as $key => $value) {
        if (substr($key, 0, 6) == "right_" and $value == "1") {
            $right = substr($key, 6);
            $w = array();
            $w["user"] = $params["user_id"] + 0;
            $w["right"] = $right;
            $db->CreateUpdate(0, "user_rights", $w);
        }
    }
}
开发者ID:andreaskasper,项目名称:askbot_php,代码行数:15,代码来源:userprofile_rights.php

示例10: SQL

<?php

if (isset($_POST["act"]) && $_POST["act"] == "save") {
    $db = new SQL(0);
    $w = array();
    $w["tag"] = $params["id"];
    $w["short_desc"] = trim($_POST["short_desc"]);
    $w["long_desc"] = trim($_POST["text"]);
    $w["icon_URL"] = trim($_POST["icon_URL"]);
    $db->CreateUpdate(0, 'tag_details', $w);
    PageEngine::AddSuccessMessage("save", "Artikel gespeichert");
}
开发者ID:andreaskasper,项目名称:askbot_php,代码行数:12,代码来源:tags_infoedit.php

示例11: SQL

<?php

if (isset($_POST["action"]) and $_POST["action"] == "save") {
    $db = new SQL(0);
    $info = $db->cmdrow(0, 'SELECT T1.*, T2.title FROM answers as T1 LEFT JOIN questions as T2 ON T1.question=T2.id WHERE T1.id={0} LIMIT 0,1', array($params["id"] + 0));
    if ($info["author"] != MyUser::id() && !isset($_SESSION["myuser"]["lastwritten"]["answers"][$info["id"]])) {
        die("Dies ist nicht Ihre Frage.");
    }
    $w = array();
    $w["keyid"] = $info["id"];
    $w["type"] = "a";
    $w["title"] = "";
    $w["text"] = $info["txt"];
    $w["user"] = MyUser::id();
    $w["dt_created"] = time();
    $db->CreateUpdate(0, 'qatext_versions', $w);
    $w2 = array();
    $w2["id"] = $info["id"];
    $w2["txt"] = $_POST["text"];
    $w2["author"] = MyUser::id();
    $w2["date_edited"] = time();
    $db->CreateUpdate(0, 'answers', $w2);
    $w3 = array();
    $w3["id"] = $info["question"] + 0;
    $w3["date_action"] = time();
    $w3["user_action"] = MyUser::id();
    $db->CreateUpdate(0, 'questions', $w3);
    Badges::add(10, MyUser::id());
    //Erfolg Redakteur: Editiere einen Beitrag
    header("Location: " . Question::PermalinkByData($info["question"], $info["title"]) . "#answer-" . $w2["id"]);
    exit(1);
开发者ID:andreaskasper,项目名称:askbot_php,代码行数:31,代码来源:answer_edit.php

示例12: write

     if (!isset($r) or $r === null) {
         return $default;
     } else {
         return $r;
     }
 }
 public static function write($id, $data)
 {
     if ($id . "" == "") {
         return false;
     }
     if (isset(self::$datapart[$id])) {
         self::$datapart[$id] = array_merge(self::$datapart[$id], $data);
     } else {
         self::$datapart[$id] = $data;
     }
开发者ID:andreaskasper,项目名称:askbot_php,代码行数:16,代码来源:class.SiteConfig.php

示例13: OpenIDAddLogin

 $id = $openid->data["openid_identity"];
 $email = $openid->data["openid_ax_value_email"];
 $nickname = $openid->data["openid_ax_value_nickname"];
 $language = $openid->data["openid_ax_value_language"];
 $gender = $openid->data["openid_ax_value_gender"];
 //print_r($openid); exit(1);
 if (MyUser::isloggedin()) {
     OpenIDAddLogin($id, array("email" => $email, "nickname" => $nickname, "language" => $language, "gender" => $gender));
 } else {
     OpenIDRegisterLogin($id, array("email" => $email, "nickname" => $nickname, "language" => $language, "gender" => $gender));
     exit(1);
开发者ID:andreaskasper,项目名称:askbot_php,代码行数:11,代码来源:login.php

示例14: SQL

	<p>Jetzt wird die Konfiguration angelegt</p>
	<fieldset>
		<legend>Fortschritt</legend>
		<table class="std01">
		
		<?php 
include $_ENV["basepath"] . "/app/code/classes/class.SQL.php";
$db = new SQL(0, "mysql://" . $_POST["mysql_username"] . ":" . $_POST["mysql_password"] . "@" . $_POST["mysql_host"] . ":" . $_POST["mysql_port"] . "/" . $_POST["mysql_database"] . "/");
?>
		<tr><th>Öffne Datenbank-Server:</th><td class="yes">fertig...</td></tr>
		<?php 
$f = file_get_contents($_ENV["basepath"] . "/app/code/install.mysql.sql");
$i = 0;
$command = "";
foreach (explode(chr(13), str_replace(chr(10), chr(13), $f)) as $line) {
    $i++;
    if (substr($line, 0, 2) == "--") {
        continue;
    }
    if (substr($line, 0, 1) == " " or substr($line, 0, 1) == ")") {
        $command .= $line;
        continue;
    }
    //echo($command.'<br/>');
    if (trim($command) != "") {
        $db->cmd(0, $command, true);
    }
    $command = $line;
}
//echo($command.'<br/>');
if (trim($command) != "") {
开发者ID:andreaskasper,项目名称:askbot_php,代码行数:31,代码来源:install_page5.php


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