|
@@ -112,11 +112,21 @@
|
|
|
`(:div (:input :type "radio" :name ,label :value ,value)
|
|
|
,name (:br))))
|
|
|
|
|
|
+(defun make-update-query (table columns fields)
|
|
|
+ (let ((actual-query (format nil "INSERT INTO ~a (~{~a~^, ~}) values (~{~a~^, ~})"
|
|
|
+ table
|
|
|
+ columns
|
|
|
+ (iter (for i in columns)
|
|
|
+ (collect "?"))))
|
|
|
+ (fields (iter (for field in fields)
|
|
|
+ (collect `(post-parameter ,field)))))
|
|
|
+ `(execute-non-query *db* ,actual-query ,@fields)))
|
|
|
+
|
|
|
(defmacro define-form (name table (&rest fields) &key &allow-other-keys)
|
|
|
(let* ((columns (map 'list #'second fields))
|
|
|
(field-names (map 'list #'(lambda (column)
|
|
|
(concatenate 'string "fld_" column))
|
|
|
columns))
|
|
|
- (form-entries (map 'list #'make-form-entry fields)))
|
|
|
- `(list (list ,@columns)
|
|
|
- (list ,@field-names))))
|
|
|
+ (form-entries (map 'list #'make-form-entry fields))
|
|
|
+ (update-query (make-update-query table columns field-names)))
|
|
|
+ ))
|