Table of Contents

Viewing Arrays in the Lens

If you want to view PHP session variables in phpLens (instead of the results of an SQL statement), we have a solution. Use PHPLensArray( ) instead of PHPLensConnect( ) or PHPLensPConnect( ) to create a phpLens object. This function allows you can pass a PHP array to phpLens for display and editing.

For example:

<?php
include_once(PHPLENS_DIR.'/phplens.inc.php');
session_start();

$lens = PHPLensArray('some_lens_id', array('field1'=> 'My name', 'field2' => 9999) ); 
$lens->Render();
?>

Will display the standard phpLens screen:

All changes made to this array will be saved in the session variable array $ARRAY_some_lens_id. If you want to reload the data array and lose all changes, call

PHPLensArrayReset('some_lens_id); 

Source code for these functions can be found phplens-common.inc.php.

Limitations

Most phpLens properties can be used, except that you cannot delete nor create new records. The spEdit property is used internally to manage this data, so do not modify this property.

Reference

function &PHPLensArray($id,$data,$types=false,$cols=false,$lang=PHPLENS_LANG_DEFAULT)

Returns: A phpLens object or false on failure.

Example:

$id = 'MY_ID';
$data = array('Jacky', 'Chan','1954-12-30', 180);
$types = array('C',    'C',    'D'        , I);
$cols = array('firstn','lastn','bday',    ,'height');
$lens = PHPLensArray($id, $data, $types, $cols);

function PHPLensArrayReset($id)

This deletes the ARRAY_$id session variable, so that the $data array in PHPLensArray( ) is reloaded.