Skip to content

Commit c671d40

Browse files
author
root
committed
fixed updating empty row in SQL
1 parent 8bec148 commit c671d40

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

db/db_structure.sql

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
-- MySQL dump 10.13 Distrib 5.5.31, for debian-linux-gnu (x86_64)
1+
-- MySQL dump 10.13 Distrib 5.5.35, for debian-linux-gnu (x86_64)
22
--
33
-- Host: localhost Database: CVreviewTool
44
-- ------------------------------------------------------
5-
-- Server version 5.5.31-0ubuntu0.12.04.1
5+
-- Server version 5.5.35-0ubuntu0.12.04.2
66

77
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
88
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -40,7 +40,7 @@ CREATE TABLE `citations` (
4040
PRIMARY KEY (`id`),
4141
KEY `person_id` (`person_id`),
4242
CONSTRAINT `citations_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `person` (`id`)
43-
) ENGINE=InnoDB AUTO_INCREMENT=309 DEFAULT CHARSET=latin1;
43+
) ENGINE=InnoDB AUTO_INCREMENT=313 DEFAULT CHARSET=latin1;
4444
/*!40101 SET character_set_client = @saved_cs_client */;
4545

4646
--
@@ -60,7 +60,7 @@ CREATE TABLE `person` (
6060
`department` varchar(255) DEFAULT NULL,
6161
`school` varchar(255) DEFAULT NULL,
6262
PRIMARY KEY (`id`)
63-
) ENGINE=InnoDB AUTO_INCREMENT=42 DEFAULT CHARSET=latin1;
63+
) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=latin1;
6464
/*!40101 SET character_set_client = @saved_cs_client */;
6565

6666
--
@@ -92,8 +92,11 @@ CREATE TABLE `templates` (
9292
`id` int(11) NOT NULL AUTO_INCREMENT,
9393
`template_id` varchar(255) DEFAULT NULL,
9494
`template_text` varchar(10000) DEFAULT NULL,
95-
PRIMARY KEY (`id`)
96-
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
95+
PRIMARY KEY (`id`),
96+
UNIQUE KEY `id` (`id`),
97+
UNIQUE KEY `template_id` (`template_id`),
98+
UNIQUE KEY `template_id_2` (`template_id`)
99+
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=latin1;
97100
/*!40101 SET character_set_client = @saved_cs_client */;
98101
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
99102

@@ -105,4 +108,4 @@ CREATE TABLE `templates` (
105108
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
106109
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
107110

108-
-- Dump completed on 2014-03-16 19:46:53
111+
-- Dump completed on 2014-03-17 17:01:34

template_edit.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,8 @@
77
$template_id = $_POST['template_id'];
88
$author_id = $_POST['author_id'];
99

10-
// echo $template_edit;
11-
// echo $template_id;
12-
// echo $author_id;
13-
1410
//db insert
15-
$query = "UPDATE templates SET template_text = '$template_edit' WHERE template_id = '$template_id'";
11+
$query = "INSERT INTO templates (template_id, template_text) VALUES ('$template_id','$template_edit') ON DUPLICATE KEY UPDATE template_text = VALUES(template_text)";
1612

1713
if (!@$CVreviewTool_dbconnect->query($query)) {echo $query; die; }
1814

0 commit comments

Comments
 (0)