Just add the following to your mysql5.lsp file:
Code: Select all
(define (fetch-all , all)
"Redefined fetch-all that is not affected by previous results, nor does it
affect future results."
(dotimes (x (num-rows)) (push (fetch-row) all))
(reverse all))
(import libmysqlclient "mysql_num_fields")
(define (num-fields)
"Evaluates the total number of fields for the current result."
(mysql_num_fields MYSQL_RES))
(import libmysqlclient "mysql_fetch_field")
(define (result-fields)
"Generates a list of strings reflecting the names of the fields in the
current result."
(let ((fields '()))
(dotimes (i (num-fields))
(push (get-string (get-int (mysql_fetch_field MYSQL_RES)))
fields -1)) fields))
(define (fetch-table)
"Creates a table associating field names with field values for the current
result. This will not work if the result has already been pulled another
way."
(letn ((rows (fetch-all)) (fields (result-fields))
(pair (lambda (row) (map list fields row))))
(map pair rows)))