function clearTransaction($orderNumber, $response) { sqlconnect(); $sql = "update monetTransaction set paymentStatus = " . toSql($response->paymentStatus) . ", authCode = " . toSql(null) . ", updated=NOW(), payId=" . toSql(null) . " where orderNumber = " . toSql($orderNumber); $this->log->write($sql); sqlExecute($sql); }
<?php require "mysqlconf.php"; header("content-type:application/json;charset:utf-8;"); $res = array(); function sqlExecute($db, $data) { $stmt = $db->prepare("update `test_8051` set A101 = :A101, A102 = :A102, A103 = :A103, A104 = :A104,\n\t\t\t\t A201 = :A201, A202 = :A202, A203 = :A203, A204 = :A204"); $stmt->execute(array(":A101" => $data["A101"], ":A102" => $data["A102"], ":A103" => $data["A103"], ":A104" => $data["A104"], ":A201" => $data["A201"], ":A202" => $data["A202"], ":A203" => $data["A203"], ":A204" => $data["A204"])); return $stmt->rowCount(); } try { if (isset($_POST)) { if (isset($_POST["method"])) { $res = array("result" => '' . sqlExecute($dbc, json_decode($_POST["method"], true))); } else { $res = array("result" => '0'); } } } catch (PDOException $e) { echo $e; } echo json_encode($res, JSON_HEX_TAG);
switch ($result) { case "success": error("添加成功!", "alertGoTo", $_SERVER['HTTP_REFERER']); break; case "error": error($news->getActionError(), "alertGoTo", $_SERVER['HTTP_REFERER']); break; } } if ($action == "doRm") { $id = isset($_POST["id"]) ? intval($_POST["id"]) : ""; if (empty($id)) { jsonError("fail", "id为空"); } $sql = "delete {$mysqlConfig["db_perfix"]}web_news where id = {$id} limit 1"; sqlExecute($sql, "", "json"); jsonError("succ"); } if ($action == "doMod") { $news = new news(); $result = $news->modi(); switch ($result) { case "success": error("添加成功!", "alertGoTo", $_SERVER['HTTP_REFERER']); break; case "error": error($news->getActionError(), "alertGoTo", $_SERVER['HTTP_REFERER']); break; } } jsonError("fail", "action is null");
public function modi() { $this->news["id"] = isset($_REQUEST["id"]) ? $_REQUEST["id"] : ""; if (empty($this->news["id"])) { $this->addActionError("id", "id为空"); return parent::ERROR; } $this->news["news_title"] = isset($_REQUEST["news_title"]) ? $_REQUEST["news_title"] : ""; if (empty($this->news["news_title"])) { $this->addActionError("news", "标题为空"); return parent::ERROR; } $this->news["news_type"] = isset($_REQUEST["news_type"]) ? $_REQUEST["news_type"] : "1"; $this->news["news_content"] = isset($_REQUEST["news_content"]) ? $_REQUEST["news_content"] : ""; if (empty($this->news["news_content"])) { $this->addActionError("news", "文章内容为空"); return parent::ERROR; } /*截取前20个字, strip_tags指去掉html标记*/ $this->news["news_content_short"] = substr(clearHtml($this->news["news_content"]), 0, 20); $this->news["news_content_short"] = empty($this->news["news_content_short"]) ? "此条新闻没有文本内容" : $this->news["news_content_short"]; $this->news["uid"] = isset($_REQUEST["uid"]) ? $_REQUEST["uid"] : "admin"; $this->news["isPublish"] = isset($_REQUEST["isPublish"]) ? $_REQUEST["isPublish"] : "1"; $this->news["news_post_time"] = !empty($_REQUEST["news_post_time"]) ? $_REQUEST["news_post_time"] : date("Y-m-d H:i:s", time()); $sql = "update " . $this->mysqlConfig["db_perfix"] . "web_news \r\n\t\t\t\tset \r\n\t\t\t\tnews_title = '{$this->news["news_title"]}',\r\n\t\t\t\tnews_content = '{$this->news["news_content"]}',\r\n\t\t\t\tnews_type_id = '{$this->news["news_type"]}',\r\n\t\t\t\tnews_content_short = '{$this->news["news_content_short"]}',\r\n\t\t\t\tuid = '{$this->news["uid"]}',\r\n\t\t\t\tisPublish = '{$this->news["isPublish"]}',\r\n\t\t\t\tnews_post_time = '{$this->news["news_post_time"]}',\r\n\t\t\t\tnews_title = '{$this->news["news_title"]}'\r\n\t\t\t\twhere id = {$this->news["id"]}\r\n\t\t\t\t"; $rs = sqlExecute($sql); return parent::SUCCESS; }
$sql = getSqlSchema(Db::$dbName, Db::$tablePrefix); if (isset($_POST['createDatabase']) && $_POST['createDatabase'] == true) { // create the database if needed. try { $dbh = new PDO('mysql:host=' . Db::$dbHost . ';port=' . Db::$dbPort, Db::$dbUser, Db::$dbPwd); $dbh->exec($sql['base']['create']) or die('Erreur lors de la création de la base<br />' . print_r($dbh->errorInfo(), true)); } catch (PDOException $e) { die("DB ERROR: " . $e->getMessage()); } } if (isset($_POST['dropTables']) && $_POST['dropTables'] == true) { sqlExecute($sql['User']['drop']); sqlExecute($sql['favorite']['drop']); } sqlExecute($sql['User']['create']); sqlExecute($sql['favorite']['create']); $result .= '<p class="true">Les tables correspondantes ont été initialisées dans la Base-de-données</p>'; /* This is nowDoc (hereDoc 2.0 ;-) */ $config = <<<'EOD' namespace Transitive; /* * Architecture-related */ define('ROOT_PATH', dirname(dirname(__FILE__))); define('SELF', (dirname($_SERVER['PHP_SELF']) == '/' ? '' : dirname($_SERVER['PHP_SELF']))); define('CONTROLLERS_INC', ROOT_PATH.'/controllers/'); define('MODELS_INC', ROOT_PATH.'/models/'); define('VIEWS_INC', ROOT_PATH.'/views/'); define('DATA_PATH', ROOT_PATH.'/data/');