[ PHPXref.com ] [ Generated: Sun Jul 20 19:45:06 2008 ] [ PhpLabware 0.6 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/includes/ -> db_inc.php (summary)

functions interfacing with the databaseauthor: Nico Stuurman <nicost@soureforge.net>

File Size: 1656 lines (59 kb)
Included or required: 11 times
Referenced: 0 times
Includes or requires: 1 file
 includes/defines_inc.php

Defines 1 class

tableinfo:: (40 methods):
  tableinfo()
  array_key_exists()
  GetValuesMenu()
  comma_array_SQL_where()
  comma_array_SQL()
  origin_column()
  sortstring()
  tableheader()
  add()
  update_mpulldown()
  modify()
  delete()
  process_image()
  upload_files()
  get_files()
  file_path()
  delete_column_file()
  delete_file()
  user_array()
  show_access()
  get_access()
  may_read_SQL_subselect()
  make_SQL_ids()
  may_read_SQL_JOIN()
  may_read_SQL()
  make_temp_table()
  may_read()
  may_write()
  make_SQL_csf()
  typevalue()
  numerictoSQL()
  datetoSQL()
  searchhelp()
  search()
  first_last_page()
  next_previous_buttons()
  paging()
  current_page()
  make_search_SQL()
  may_see_table()


Class: tableinfo  - X-Ref

tableinfo($db,$realname=false,$id=false)   X-Ref
No description

array_key_exists($find,$array)   X-Ref
No description

GetValuesMenu($db,$selectname,$selected,$tablename,$columnname,$whereclause=false,$jscript=false)   X-Ref
*
Analogue of adodb GetMenu2, but display referenced values (using getvalues)


comma_array_SQL_where($db,$tablein,$column,$searchfield,$searchval)   X-Ref
*
SQL where search that returns a comma delimited string


comma_array_SQL($db,$tablein,$column,$where=false)   X-Ref
*
SQL search (entrire column) that returns a comma delimited string


origin_column($db,$tableinfo,$key)   X-Ref
Helper function for sortstring

returns a string with format tablename.columnname, reflecting the data source for the specified column

sortstring($db,$tableinfo,&$sortdirarray,$sortup,$sortdown)   X-Ref
Update sortdirarray and returns formatted sortdirstring


tableheader($sortdirarray,$nowfield)   X-Ref
Displays header of 'general' table


add($db,$table,$fields,$fieldvalues,$USER,$tableid)   X-Ref
Inserts $fields with $fieldvalues into $table

Returns the id of inserted record on succes, false otherwise.
$fields is a comma separated list with all column names
Fieldvalues must be an associative array containing all the $fields to be added.
Fields named 'date' are automatically filled with a Unix timestamp

update_mpulldown($db,$key_table,$recordid,$valueArray)   X-Ref
For multiple choice pulldowns.

Deletes entries in key_table for a give record,and then re-inserts the ones present in the array

modify($db,$table,$fields,$fieldvalues,$id,$USER,$tableid)   X-Ref
Modifies $fields in $table with values $fieldvalues where id=$id

Returns true on succes, false on failure
Fieldvalues must be an associative array containing all the $fields to be added.
If a field is not present in $fieldvalues, it will be set to NULL.
The entry 'id' in $fields will be ignored.
Fields lastmodby and lastmoddate will be automatically set

delete($db, $tableid, $id, $USER, $filesonly=false)   X-Ref
Deletes the entry with id=$id

Returns true on succes, false on failure
Checks whether the delete is allowed
This is very generic, it is likely that you will need to do more cleanup

process_image($db,$fileid,$bigsize)   X-Ref
Generates thumbnails and extracts information from 2-D image files


upload_files($db,$tableid,$id,$columnid,$columnname,$USER,$system_settings)   X-Ref
!Upload files and enters then into table files
Filetitle in _POST will be inserted in the title field of table files
Returns id of last uploaded file upon succes, false otherwise


get_files($db,$table,$id,$columnid,$format=1,$thumbtype='small')   X-Ref
returns an array with id,name,title,size, and hyperlink to all

files associated with the given record

file_path($db,$fileid)   X-Ref
Returns path to the file


delete_column_file($db,$tableid,$columnid,$recordid,$USER)   X-Ref
Deletes all file associated with this record,column and table


delete_file($db,$fileid,$USER)   X-Ref
Deletes file identified with id.

Checks 'mother table' whether this is allowed
Also deletes entries in index table for this file
Returns name of deleted file on succes

user_array($db)   X-Ref
Returns a 2D array with id and full name of all users

called by show_access

show_access($db,$tableid,$id,$USER,$global_settings)   X-Ref
Prints a table with access rights

input is string as 'rw-rw-rw-'
names are same as used in get_access

get_access($fieldvalues,$column)   X-Ref
Returns a formatted access strings given an associative array

with 'grr','evr','grw','evw' as keys

may_read_SQL_subselect($db,$table,$tableid,$USER,$clause=false)   X-Ref
Returns an SQL SELECT statement with ids of records the user may see

Since it uses subqueries it does not work with MySQL

make_SQL_ids($r,$ids,$field='id')   X-Ref
returns a comma-separated list of quoted values from a SQL search

helper function for may_read_SQL

may_read_SQL_JOIN($db,$table,$USER)   X-Ref
Returns an array with ids of records the user may see in SQL format

Works with MySQL but not with early postgres 7 versions (current ones should
work)

may_read_SQL($db,$tableinfo,$USER,$temptable='tempa')   X-Ref
Generates an SQL query asking for the records that may be seen by this user

Generates a left join for mysql, subselect for postgres

make_temp_table($db,$temptable,$r)   X-Ref
Generates a temporary table from given recordset


may_read($db,$tableinfo,$id,$USER)   X-Ref
determines whether or not the user may read this record
When recordid is not set, report an error and return false, otherwise retrun true when the record with this id can be read, false otherwise
When the record does not exist return false


may_write($db,$tableid,$id,$USER)   X-Ref
checks if this user may write/modify/delete these data


make_SQL_csf($r,$ids,$field="id",&$column_count)   X-Ref
returns an comma-separated list of quoted values from a SQL search

derived from make_SQL_ids but can be called from anywhere

typevalue($value,$type)   X-Ref
helperfunction for numerictoSQL


numerictoSQL(&$tableinfo,$searchterm,$column,$type,$and)   X-Ref
interprets numerical search terms into an SQL statement

implements ranges (i.e. 1-6), and lists (1,2,3) and combinations thereof
< and > can also be used

datetoSQL($searchterm,$column,$and)   X-Ref
Converts a (textual) date range into a meaningfull SQL statement

Start and end are separated with '-'
dates can be in current local (12/24/03), or textual (today, last month,etcc.)
Alternatively, a single date can be preceded with a '<' or '>'
I am not sure how strtotime deals with US versus European standards...

searchhelp($db,$tableinfo,$column,&$columnvalues,$query,$wcappend,$and)   X-Ref
Helper function for search

Interprets fields the right way

search($db,$tableinfo,$fields,&$fieldvalues,$whereclause=false,$wcappend=true)   X-Ref
Returns an SQL search statement

The whereclause should NOT start with WHERE
The whereclause should contain the output of may_read_SQL and
can also be used for sorting

first_last_page(&$r,&$current_page,$r_p_p,$numrows)   X-Ref
sets AtFirstPage and AtLastPage


next_previous_buttons($r,$paging=false,$num_p_r=false,$numrows=false,$pagenr=false,$db=false,$tableinfo=false,$viewid=false)   X-Ref
Displays the next and previous buttons

$r is the result of a $db->Execute query used to display the table with records
When $paging is true, the records per page field will also be displayed
$num_p_r holds the (global) records per page variable

paging($num_p_r,&$USER)   X-Ref
Returns the variable $num_p_r holding the # of records per page

check user settings and GET_VARS
Write the value back to the user defaults
When no value is found, default to 10

current_page($curr_page, $sname, $num_p_r, $numrows)   X-Ref
Returns current page

current page is table specific, therefore
The variable name is formed using the short name for the table

make_search_SQL($db,$tableinfo,$fields,$USER,$search,$searchsort,$whereclause=false)   X-Ref
Assembles the search SQL statement and remembers it in _SESSION


may_see_table($db,$USER,$tableid)   X-Ref
Checks whether a user has access to a given table




[ Powered by PHPXref - Served by Debian GNU/Linux ]