<?php
/*
	Demo (c)2002 Remistech Sdn Bhd.
*/
include('phplens.inc.php');


$DB = ADONewConnection('mysql');
// server, user, pwd, database
$server = 'localhost';
$DB->Connect($server,'root','','northwind'); ## change HOST here

/*
//------------------------------------------------------------------------
//  Define the following in phplens.config.inc.php so phplens_remoteq.php
//  is able to retrieve the correct states and cities and send it back to
//  the browser.

$PHPLENS_DATABASES = 
array(			//driver, server, userid, pwd, database
	'testdb' => array('mysql','192.168.0.7','root','','test')  ## change HOST here
);

*/


$lens = new PHPLens('id_test', $DB, 'select * from people');

//-------------------------------------
// define update table and primary key
$lens->keyTable = 'people';
$lens->keyCol = 'name';

//-----------------------------------------
// make lens editable and allow new record
$lens->canEdit = true;
$lens->canNew = true;

//---------------------------------
// allow editing of multiple records
$lens->editMultiple = true;
//$lens->templateGridHdr = 'hotupdate-gridhdr.shtml';
//$lens->templateGrid = 'hotupdate-grid.shtml';

//-----------------------------------------------------------------
// {country} {state} map to the popup fields in new and edit record
$lens->lookupLens = 
  "STATE^#select distinct state from cities where country={country} order by 1;".
  "COUNTRY^#select distinct country from cities order by 1;".
  "CITY^#select distinct city from cities where country={country} and state = {state} order by 1";

//--------------------------------------------------------------
// phplens_remoteq.php will use this database connection setting
// defined in phplens.config.inc.php
$lens->phplensDatabase = 'testdb'; 
// generate the html
$lens->Render();
$lens->Close();
?>
