This PHP library is intended to make quickly a user fiendly web interface to a postgresql database. It is thinked to be configurable, manage automaticly references betwhin tables, has multilanguage support, and could be extended quite easly. It is not intended as admin tool (see phpPgAdmin), but as an intuitive web mask to a database. It supports also file upload that could be stored in your file system or directly in the database as a postgres large object. Creates automaticly thumbnail if a image is uploaded and read exif information (metadata headers of image generated by digital cameras)
magic_quotes_gpc
is set to Off
. Set this in your php.ini file or in apache web server configuration file write php_admin_value magic_quotes_gpc Off
It works with all tested browser. With text browser links some non essential javascript function don't works, but it is usable.
pg_connect()
function. add_table()
specifing as parameters the schema name, the table name and if you want the primary key column name. See Pgtable Class Reference for more details (or ./html/tables.php). switch_action()
method, specifing as parameters the schema name and the table name. This return a hash with keys:
enctype="multipart/form-data"
if you want submit files (see ./html/tables.php). It could be similar to this: <form name="pgform" method="POST" enctype="multipart/form-data" action="<?=$_SERVER["PHP_SELF"]>"?>
Note that it is important to specify form name that corespond with formName specified in the configuration file of your Pgclass object (see ./conf/pgtbconf.ini). It is used by javascript for tables references.
Here is an example:
SQL code to create table:
CREATE TABLE lobjecttable( note text, file_size bigint, file_name varchar, file_type varchar, file_thumbnail oid, file_file oid, file_exif varchar );now you have to call
alterType()
method of object Pgtable to change the visualization mode as specified at point 5 of section How use this library:
$pgtable->alterType('public', 'lobjecttable','file_file', "lobject", array( "type"=>'', 'mime_type_col'=>'file_type', 'name_col'=>'file_name', 'size_col'=>'file_size', 'thumbnail_col'=>'file_thumbnail', 'exif_col'=>'file_exif', "thumbnail_size"=>120 ) );
"type" could be an array of mime_type allowed or of a part of mime_type allowed (for example "type"=>array("image", "application/pdf")
if you want to store only images and pdf)
See alterType()
function references for details or more features and .html/tables.php for an example.
Here is an example:
SQL code to create table:
CREATE TABLE filetable( note text, file_size bigint, file_name varchar, file_type varchar, file_thumbnail varchar, file_file varchar, file_exif varchar );now you have to call
alterType()
method of object Pgtable to change the visualization mode as specified at point 5 of section How use this library:
$pgtable->alterType('public', 'filetable','file_file', "file", array( "type"=>'', 'mime_type_col'=>'file_type', 'name_col'=>'file_name', 'size_col'=>'file_size', 'thumbnail_col'=>'file_thumbnail', 'exif_col'=>'file_exif', "thumbnail_size"=>120 ) );
"type" could be an array of mime_type allowed or of a part of mime_type allowed (for example "type"=>array("image", "application/pdf")
if you want to store only images and pdf)
See alterType()
function references for details or more features and .html/tables.php for an example.
For thise two ways, there is a small poblem of integrity: if your table in wich there is stored the large object or the file name, could be modified from other interfaces different form phppgweb or has a references on another table, created with "on delete cascade" clause, there is the possibility to remove only the record without deleting file or large object or the possibility to insert inexistents files or large object. So only in thise particula cases it is better to create a control trigger that delete large object or file when a delete occurs or when an update change the refer to the file.
Change language is simple: you hace to modify de file specified by strings parameter into the configuration file of your Pgclass configuration file(specified whan the class is initialized). (see ./conf/pgtbconf.ini for an example)
If your language not exist create a copy of existent file and translate the few strings presents in it. You can so send me this file to add support for other languages.
In other case you can join explicitly tables with join_parent()
and join_child()
methods of Pgtable class. If your rferenced table is quite small and you want a select input against the default popup window, you could do this with alter_parent()
method of Pgtable class. This is an example to be called as specified at point 5 of section How use this library:
$pgtable->alter_parent('child_table_schema_name', 'child_table_name', 'child_table_column_name', array("type"=>"select"));
If you will display another column of referenced table or a mix of its column you can call the function in this way:
$pgtable->alter_parent('child_table_schema_name', 'child_table_name', 'child_table_column_name', array("type"=>"select", "query"=>"SELECT ref_table_column as \"OID\", surname ||' '|| name as child_table_column_name from ref_table_schema.ref_table_name" ) );Note that it is important to rename appopriatly the query results as in the example, and that OID corespond to referenced column name of child table.
actions
of Pgtable class. $pgtable->actions[table_schema_name][table_name]=array('search','edit','insert','delete','view', 'preMultipleInsert', 'copy', 'modifySearch', 'multipleInsert');You can reset this attribute to only some values of the above in the part specified at point 5 of section How use this library.