Packageindex Classtrees Modulegroups Elementlist Report XML Files

File: g:\Work\WWW\php\tbox\lib/cdbqueryform.phps
PHP Documentation - PHP/Toolbox::Form

CDBQueryForm

CSnippet
  |
  +-- CForm
    |
    +-- CDBForm
      |
      +-- CDBQueryForm

Database query-driven form class.

 

private class CDBQueryForm extends CDBForm

Database query-driven form class.
The main idea is to use SQL-query meta-information to automatically generate appropriate form fields. | $form = new CDBQueryForm(FORM_HTML_HANDLER, | "select a, b, c, format_date("%r", date) as full_date from table_1", "where", | $PHP_SELF, "get" | ); | $form->build(array( | "field_1" => new CControl(array( | ... | )), | ... | )); | ... | $form->render();

See AlsoaddControls(), get_infield()

 
Direct known subclasses: CDBTabForm

Methods inherited from CDBForm

addcontrols, get_infield, setup_infield, setlist, set_lookup_options

Methods inherited from CForm

cform, addcontrols, addcontrol, addvars, addsubmitcancel, setmode, getvalue, invalue, outvalue, outvalues, validatevalues, validatevalue, render, renderstart, renderend, rendercontrol, renderstartcontrol, renderendcontrol, write

Methods inherited from CSnippet

csnippet, append, qualify, getglobal, setglobal, write, flush, writecode

Public Method Summary

void

CDBQueryForm(string $handler, [ string $sql, string $where, string $action, string $method, string $attrs ])

Constructs the form from the query.
void

build([ array $FIELD_DESCR ])

Builds the control list
void

fetchValues(string $where)

Fetches controls' values from the query.

Private Method Summary

mixed

process_specially(object CControl &$infield, mixed &$value)

Provide custom output (to be setList'ed) value processing.

Fields inherited from CForm

$mode, $action, $method, $controls

Fields inherited from CSnippet

$id

Private Field Summary

unknown

$sql

Public Method Details

CDBQueryForm

public void CDBQueryForm( string $handler, [ string $sql, string $where, string $action, string $method, string $attrs ] )

  Constructs the form from the query.

Parameter
string $handler
- form_html_handler (see CForm).
string $sql = >>""<<
- sql-statement to execute. It can be as simple or as complex you like.
string $where = >>"where"<<
- fetching use its own where clause that is simply appended to sql-string above. So, if 'where' clause is already specified in sql-stmt it's possible to specify fetching as additional condition -- for instance as 'and'-operator.
string $action = >>""<<
string $method = >>"get"<<
string $attrs = >>""<<
- additional fields just like in CForm and CSnippet.
Returns void


build

public void build( [ array $FIELD_DESCR ] )

  Builds the control list
using the form sql-query meta-info.

Parameter
array $FIELD_DESCR = >>array()<<
Returns void


fetchValues

public void fetchValues( string $where )

  Fetches controls' values from the query.
It performs some std processing, like converting csv-lists into arrays and uses control's inValue() to possibly customize the value processing as well.

Parameter
string $where
- fetching use its own where clause that is simply appended to form sql-string: "$this->sql $this->where $where"
Returns void

See Also CDBQueryForm()

Private Method Details

process_specially

private mixed process_specially( object CControl &$infield, mixed &$value )

  Provide custom output (to be setList'ed) value processing.
By default:
  • if value isn't set returns 'null';
  • if field type is a 'password' returns password('value')
    (it's not quite sequre and is subject to polish);
  • if value is an array joins it with ','.

Parameter
object CControl &$infield
- in.
mixed &$value
- inout.
Returns mixed

- value.


Private Field Details

$sql

private unknown $sql

>><<




Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta