NYCPHP Meetup

NYPHP.org

phpSQLGen 0.3.0 released

Liquid M3 liquidm3 at hotmail.com
Wed Jul 17 21:48:28 EDT 2002


phpSQLGen provides a library of functions for generating SQL queries from 
arrays and HTML tables from database result sets (ADOdb) or arrays.

For more information, see
http://www.liquidmarkets.com/?name=XForum&file=viewthread&tid=2
http://sourceforge.net/projects/phpsqlgen/
http://www.liquidmarkets.com/phpxref/phpsqlgen/index.php#documentation
http://www.liquidmarkets.com/?name=djia&y=1998 (example program)

New in release 0.3.0:
1) improved integration between SQLGen and TableMaker (note in the example 
below how TableMaker uses the same $cols array that SQLGen uses to generate 
the query)
2) support for fetch mode num. This improves performance and cross-database 
compatibility, since some databases don't support the associative fetch mode
3) better handling of column headers (TableMaker)
4) better handling of "as" (SQLGen and TableMaker)
5) better handling of multiple-table selects (SQLGen)

Example program:
<?php
/*
* Copyright (c) 2002, Ted Shieh (http://www.liquidmarkets.com/?name=contact)
* All rights reserved
* This program is released under the BSD license.
*/

## @author <a href="http://www.liquidmarkets.com/?name=contact">Ted 
Shieh</a>

## phpSQLGen example program. Lists the low, date of low, high, and date of 
high
## for the Dow Jones Industrial Average for each month of 1998.
## See http://www.liquidmarkets.com/?name=djia&y=1998

$web_dir = $_SERVER['DOCUMENT_ROOT'];
include_once("$web_dir/phpsqlgen/phpsqlgen-utils.php");
$separator = get_separator();
ini_set('include_path', ".$separator$web_dir/pear");
include_once("$web_dir/pear/HTML/Table.php");
include_once("$web_dir/phpsqlgen/SQLGen.php");
include_once("$web_dir/phpsqlgen/TableMaker.php");
include_once("$web_dir/pnadodb/adodb.inc.php");

$conn = &ADONewConnection("mysql");
$conn->PConnect('localhost', 'user', 'pass', 'database');
print "<h1>Dow Jones Industrial Average Historical Data</h1>\
";
$cols = array('y=>Year', 'm=>Month', 'low=>Low', 'dt_low=>Date of Low', 
'high=>High', 'dt_high=>Date of High');
$options['where'] = array("y = 1999");
$sql = SQLGen::gen_select(array('djia_month'),$cols,$options);
$rs = $conn->Execute($sql);
$tm = new TableMaker();
$tm->display('adodb',$rs,$cols,$display_options);
?>


Ted

LiquidMarkets
Financial data and free classifieds
http://www.liquidmarkets.com


_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com




More information about the talk mailing list