This function is used for singleton queries (queries that return one row of data). Since it returns data as a hash it is ideal for dealing with user input forms. The key represents the column, the value the data element.
Syntax:
$rs = dbread(~query as string or variable containing query~,'hash');
Example:
$rs = dbread($query,'hash');
Accessing Data Returned:
syntax:
$rs['~column or alias name~']
example:
Assuming query ...
$query = 'SELECT
course_name as 'Course',
education_delivery_method,
max_recommended_enrollment,
convenings
FROM Courses where course_designater = \'Word100\'
';
...
$rs['Course'];
$rs['education_delivery_method'];
The following FUNCTIONS use this query.
$query = 'SELECT
course_name,
education_delivery_method,
max_recommended_enrollment,
convenings
FROM Courses LIMIT 100
';
This function is used to execute a query and bind it to a grid control. The grid control I am using was created by Matt Kruse. It is an api that he created using Javascript.
When using this function bound to the grid control it is important to understand that each item in the select MUST be mapped to the grid control.
Syntax:
$rs = dbread(~query as string or variable containing query~,'trrow');
Example:
$rs = dbread($query,'trrow');
Example binding to grid control.
The grid code is seperate and not covered here.
Returns data in an array. Each row is an element in the array. The data is delimited. The delimiter can be set to any value or string. It is set to |
Syntax:
$rs = dbread(~query as string or variable containing query~,'delim');
Example:
$rs = dbread($query,'delim');
returns data ...
Introduction to Word|Classroom|16|1
Introduction to Powerpoint|Classroom|16|1
Advanced Perl Programming|Classroom|10|5
Foundations in Perl Programming|Classroom|10|5
Linux - System Administration|Classroom|8|2
Introduction to SQL|Self-Study|16|0
Introduction to Linux|Classroom|16|1
Introduction to Excel|Classroom|16|5
Returns data in an array. Each row is an element in the array. The first row of data is the column names. The data is delimited. The delimiter can be set to any value or string. It is set to |
Syntax:
$rs = dbread(~query as string or variable containing query~,'delim2');
Example:
$rs = dbread($query,'delim2');
returns data ...
course_name|education_delivery_method| max_recommended_enrollment| convenings
Introduction to Word|Classroom|16|1
Introduction to Powerpoint|Classroom|16|1
Advanced Perl Programming|Classroom|10|5
Foundations in Perl Programming|Classroom|10|5
Linux - System Administration|Classroom|8|2
Introduction to SQL|Self-Study|16|0
Introduction to Linux|Classroom|16|1
Introduction to Excel|Classroom|16|5
Syntax:
$rs = dbread(~query as string or variable containing query~,'delim3');
Example:
$rs = dbread($query,'delim3');
Returns data the same as delim, except data is returned as a string not as an array. The row seperator is the newline.
Syntax:
$rs = dbread(~query as string or variable containing query~,'delim4');
Example:
$rs = dbread($query,'delim4');
This function will accept any SQL Delete, Update, or Insert statement.
Syntax:
$rs = dbwrite(~sql statement~);
Example:
$rs = dbwrite($updstmt);