MySQL API Doc

Read Functions

Assoc Array - Key/Value hash key=col val=data

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
';


String - Used for grid control, returns html table tr stub

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.


Array - Data only (default)

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


Array - Data, first elem = col name

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


String - Delimited, newline as row seperator

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.



Array - 2D Array, data only

Syntax:


$rs = dbread(~query as string or variable containing query~,'delim4');

Example:


$rs = dbread($query,'delim4');



Write Function

function dbwrite($sqlstmt)

This function will accept any SQL Delete, Update, or Insert statement.

Syntax:


$rs = dbwrite(~sql statement~);

Example:


$rs = dbwrite($updstmt);



If you find this site useful and are a book buyer/reader...

Abe Books is one of my affiliates. I only use affiliates that I also purchase products from. I love Abe books. I have purchased many books from them originally cost $40 to $60 for as little as $5 to $10 dollars including shipping costs.

By accessing Abe books and clicking on one of my links I receive a small commission on your purchase that helps pay for this site. You pay no more for your books than if you accessed their site directly. Thanks for your support.

Free Shipping 125x125

Webserver Resources

alchemy Home

alchemy Docs

alchemy Toycode

alchemy UI Templates

alchemy Builder

alchemy APIs - Database













navTango.com free

75% of your donation

goes to charity.