Dynamo

License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Quick Reference

DynamoColTableQuery($query, $columns)

Executes a query and returns an HTML table that is $columns columns wide containing the results. The $query string must return a single column of data from the database.

$query = "SELECT concat(city, ', ', state) FROM cities";

$result = DynamoColQuery($query, 3);

echo $result;

DynamoCsvQuery($query, [$header])

Executes the query and returns CSV (Comma Seperated Value) output containing the results. If you want column headings set $header to true.

$query = "SELECT firstName, lastName FROM regData WHERE id > 0";

$result = DynamoCsvQuery($query);

echo $result;

DynamoEditForm($query,$page, [$class])

Selects a row of data using the $query string, and returns an HTML form that allows the user to edit the fields returned by the $query string. The $query string must return a single row of data. When the user clicks the SUBMIT button on the generated form, it will POST field data to $page. The page that receieves the post from the editForm() call should call DynamoExecRawQuery() with an appropriate update query. The optional $class value can be included to write the output with a specific CSS class name. The default class is "dynamo".

$query = "SELECT firstName, lastName FROM cust WHERE id = 1234";

$result = DynamoEditForm($query);

echo $result;

DynamoOutputQuery($query)

Splits the string $query into multiple parts, executes the individual queries one at a time, and returns the unformatted results. Multiple queries can be included in the $query string. Multiple queries must be seperated by a semicolon.

$query = "SELECT '', '', firstname, '', '' FROM regData WHERE id > 0";

$result = DynamoOutputQuery($query);

echo $result;

DynamoRawQuery($query)

Executes the raw $query string and returns the results, if any. This function is usually used when output is not needed. Often it is used to insert a new record into the database or to update an existing record. It can be followed by an editForm() function in order to edit the newly inserted data.

$query = "INSERT INTO blog (date, subject, body) VALUES ('$date('Y-m-d')', '', '')";

$result = DynamoRawQuery($query);

$query = "SELECT date, subject, body FROM blog WHERE id = mysql_insert_id()";

editForm($query,'apply.html');

DynamoTableQuery($query, [$class], [$header])

Executes the query and returns an HTML table containing the results. Specify a $class variable to have the output be in a specific CSS class. The default class is "dynamo". If you want bolded column headings set $header to true.

$query = "SELECT firstName, lastName FROM regData WHERE id > 0";

$result = DynamoTableQuery($query);

echo $result;

DynamoVarQuery($query)

Executes the $query string and returns the resulting data as an array. The $query string must return a single row of data.

$query = "SELECT firstName, lastName FROM cust WHERE id = 1234";

$queryVal = DynamoVarQuery($query);

echo 'First Name: ' . $queryVal['firstName']; echo 'Last Name: ' . $queryVal['lastName'];

DynamoVertTableQuery($query)

Executes the query and returns a vertical HTML table containing the result. The column names are in the left column and the values are in the right column of the table. The query must return only a single result.

$query = "SELECT firstName, lastName FROM regData WHERE id = 123";

$htmlTable = DynamoVertTableQuery($query);

echo $htmlTable;