diff options
| author | Savetheinternet <savetheinternet@tinyboard.org> | 2011-12-05 10:47:30 +1100 |
|---|---|---|
| committer | Savetheinternet <savetheinternet@tinyboard.org> | 2011-12-05 10:47:30 +1100 |
| commit | fc417bc44625a509fdcc5b1320f5d5511223823c (patch) | |
| tree | 050fe726791af6a457fee8baa8af320d5eb46590 | |
| parent | c5a961a6a52af8a0d6c0085668fe71d9d9de3a9c (diff) | |
use NULL in database where possible
| -rw-r--r-- | inc/functions.php | 21 | ||||
| -rw-r--r-- | install.sql | 6 | ||||
| -rw-r--r-- | templates/posts.sql | 6 |
3 files changed, 24 insertions, 9 deletions
diff --git a/inc/functions.php b/inc/functions.php index e5feaeaa..67a9a347 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -567,10 +567,25 @@ $query = prepare(sprintf("INSERT INTO `posts_%s` VALUES ( NULL, :thread, :subject, :email, :name, :trip, :capcode, :body, :time, :time, :thumb, :thumbwidth, :thumbheight, :file, :width, :height, :filesize, :filename, :filehash, :password, :ip, :sticky, :locked, 0, :embed)", $board['uri'])); // Basic stuff - $query->bindValue(':subject', $post['subject']); - $query->bindValue(':email', $post['email']); + if(!empty($post['subject'])) { + $query->bindValue(':subject', $post['subject']); + } else { + $query->bindValue(':subject', NULL, PDO::PARAM_NULL); + } + + if(!empty($post['email'])) { + $query->bindValue(':email', $post['email']); + } else { + $query->bindValue(':email', NULL, PDO::PARAM_NULL); + } + + if(!empty($post['trip'])) { + $query->bindValue(':trip', $post['trip']); + } else { + $query->bindValue(':trip', NULL, PDO::PARAM_NULL); + } + $query->bindValue(':name', $post['name']); - $query->bindValue(':trip', $post['trip']); $query->bindValue(':body', $post['body']); $query->bindValue(':time', isset($post['time']) ? $post['time'] : time(), PDO::PARAM_INT); $query->bindValue(':password', $post['password']); diff --git a/install.sql b/install.sql index 00c67162..1d032114 100644 --- a/install.sql +++ b/install.sql @@ -182,9 +182,9 @@ CREATE TABLE IF NOT EXISTS `pms` ( CREATE TABLE IF NOT EXISTS `posts_b` ( `id` int(11) NOT NULL AUTO_INCREMENT, `thread` int(11) DEFAULT NULL, - `subject` varchar(100) NOT NULL, - `email` varchar(30) NOT NULL, - `name` varchar(35) NOT NULL, + `subject` varchar(100) DEFAULT NULL, + `email` varchar(30) DEFAULT NULL, + `name` varchar(35) DEFAULT NULL, `trip` varchar(15) DEFAULT NULL, `capcode` varchar(50) DEFAULT NULL, `body` text NOT NULL, diff --git a/templates/posts.sql b/templates/posts.sql index e3a81ee1..59df4705 100644 --- a/templates/posts.sql +++ b/templates/posts.sql @@ -1,9 +1,9 @@ CREATE TABLE IF NOT EXISTS `posts_{{ board }}` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`thread` int(11) DEFAULT NULL,
- `subject` varchar(100) NOT NULL,
- `email` varchar(30) NOT NULL,
- `name` varchar(35) NOT NULL,
+ `subject` varchar(100) DEFAULT NULL,
+ `email` varchar(30) DEFAULT NULL,
+ `name` varchar(35) DEFAULT NULL,
`trip` varchar(15) DEFAULT NULL,
`capcode` varchar(50) DEFAULT NULL,
`body` text NOT NULL,
|
