NAME
SQL.pm - essential DBI wrapper for Zanas. All subs use a unique global database connection.
sql_do
Executes a given SQL (DML) statement with supplied parameters. Returns nothing.
Synopsis
sql_do ('INSERT INTO my_table (id, name) VALUES (?, ?)', $id, $name);
sql_select_all_cnt
Executes a given SQL (SELECT) statement with supplied parameters and returns the resultset (listref of hashrefs) and the number of rows in the corresponding selection without the LIMIT
clause.
Synopsis
my ($rows, $cnt)= sql_select_all_cnt (<<EOS, ...);
SELECT
...
FROM
...
WHERE
...
ORDER BY
...
LIMIT
$start, 15
EOS
sql_select_all
Executes a given SQL (SELECT) statement with supplied parameters and returns the resultset (listref of hashrefs).
Synopsis
my $rows = sql_select_all_cnt ('SELECT id, name FROM my_table WHERE name LIKE ?', '%');
sql_select_col
Executes a given SQL (one column SELECT) statement with supplied parameters and returns the resultset (listref of hashrefs).
Synopsis
my $rows = sql_select_col ('SELECT name FROM my_table WHERE name LIKE ?', '%');
sql_download_file
Fetches file info from a given table for the current id and sends file downloading response to the client
options
- table
-
SQL table name
- path_column
-
name of the column containing the full path to the file
- file_name_column
-
name of the column containing the [original, truncated] file name
- type_column
-
name of the column containing the file MIME type
sql_upload_file
Uploads the file with given CGI name in a given directory under DocumentRoot and stores the related info into the given table for the current id
options
- table
-
SQL table name
- dir
-
directory name (relative to DocumentRoot, must be writeable by httpd, file will be named time.pid)
- path_column
-
name of the column containing the full path to the file
- file_name_column
-
name of the column containing the [original, truncated] file name
- type_column
-
name of the column containing the file MIME type
- size_column
-
name of the column containing the file size (in bytes)