]> git.proxmox.com Git - extjs.git/blame - extjs/examples/classic/simple-tasks/php/config/update.php
add extjs 6.0.1 sources
[extjs.git] / extjs / examples / classic / simple-tasks / php / config / update.php
CommitLineData
6527f429
DM
1<?php\r
2\r
3include '../connection.php';\r
4\r
5try {\r
6 $key = $_POST['key'];\r
7 $value = $_POST['value'];\r
8\r
9 // first read the config table to see if a config already exists for this key\r
10 $statement = $db->prepare("select value from config where key = '$key'");\r
11 if(!$statement->execute()) {\r
12 throw new Exception(implode(', ', $statement->errorInfo()));\r
13 }\r
14 if(!$statement->fetch(PDO::FETCH_COLUMN)) {\r
15 $sql = "insert into config (key, value) values('$key', '$value')";\r
16 } else {\r
17 $sql = "update config set value = '$value' where key = '$key'";\r
18 }\r
19\r
20 $statement = $db->prepare($sql);\r
21 if(!$statement->execute()) {\r
22 throw new Exception(implode(', ', $statement->errorInfo()));\r
23 }\r
24 $jsonResult = array('success' => true);\r
25} catch(Exception $e) {\r
26 $jsonResult = array(\r
27 'success' => false,\r
28 'message' => $e->getMessage()\r
29 );\r
30}\r
31\r
32echo json_encode($jsonResult);\r
33\r
34?>