Class JoinMatrix

Description

Similar to JoinData, but presents the options in a matrix not a list

The entries in one table can be a matrix with the coordinates from two others

We respect the 'field' interface while overriding pretty much all of it.

Typical usage:

  1.    // jointable has structure: key1 key2 field1 field2 field3...
  2.    // where key1 is the id key of table1 and key2 is the id key for table2.
  3.    // we will display field* in rows for each key2 for a given key1
  4.       $f new JoinMatrix('jointable''jtid'
  5.    $key1 new TextField('key1''label1');
  6.    $key1->setFormat('id''%s (%s)'array('name''longname'));
  7.    $key2 new TextField('key2''label2');
  8.    $f->addKeys($key1$key2);
  9.    $f1 new TextField('field1''label');
  10.    $f->addElement($f1);
  11.    $f2 new TextField('field2''label');
  12.    $f->addElement($f2);
  13.    $f->setKey($val);

Located in /inc/formslib/joinmatrix.php (line 53)

Field
   |
   --JoinMatrix
Variable Summary
string $colspan
boolean $fatal_sql
array $header1
string $joinTable
string $jtConstKeyId
string $jtIdField
string $jtVarKeyCol
Field $key1
Field $key2
integer $number
integer $numFields
array $rows
string $table1
string $table1IdCol
string $table2
array $table2All
string $table2IdCol
Method Summary
JoinMatrix JoinMatrix ( $joinTable, string $jtIdField, string $jtConstKeyCol, string $table1IdCol, string $table1, string $jtVarKeyCol, string $table2IdCol, string $table2, string $name, string $longname, [string $description = ''], string $jointable)
void addElement (Field $field, string $groupValidTest)
void addKeys (Field $key1, Field $key2)
void display ()
void displayInTable ([ $cols = 3])
void idChange ( $newId)
boolean isValid ()
void selectable ()
void selectedValue ()
void setEditable ([ $editable = false])
void setKey (integer $id)
void setNamebase ([ $namebase = ''])
void sqlSetStr ([$name $name = ''], [$force $force = false])
void update ( $data)
void _createRow (integer $rowNum)
void _fillFromProto ()
void _joinSync ()
void _populateList ()
Variables
string $colspan = 1 (line 88)
  • var: number of columns that this field should span in the table
boolean $fatal_sql = 0 (line 94)
  • var: SQL errors should be fatal (die())
array $header1 = array() (line 70)
  • var: list of Field objects to be included along the header of the matrix
string $joinTable (line 55)
  • var: name of the join table (table has columns of form (LeftID, RightID) to join Left and Right tables
string $jtConstKeyCol (line 62)
  • var: column name in the join table for the column with keys/Ids from the left table (id will be constant throughout the process)
string $jtConstKeyId (line 60)
  • var: value of the key for the left table that should be constant
string $jtIdField (line 57)
  • var: column in the join table that is the ID field for entries (unused)
string $jtVarKeyCol (line 73)
  • var: column name in the join table for the column with keys/Ids from the right table (id will vary throughout the process)
Field $key1 (line 68)
  • var: representation of the key for the left table (unused?)
Field $key2 (line 79)
  • var: representation of the key for the right table
integer $number = 0 (line 86)
  • var: number of rows in the join
integer $numFields = 0 (line 92)
  • var: number of fields that are also in the join table
DBRow $protoRow (line 82)
  • var: prototype DBRow object that is replicated for each entry in the join table (1:many join)
array $rows (line 84)
  • var: list of DBRow objects for each row returned in a 1:many join
string $table1 (line 64)
  • var: name of the left table
string $table1IdCol (line 66)
  • var: column name of ID column in the left table
string $table2 (line 75)
  • var: name of the right table
array $table2All (line 90)
  • var: list of id-pairs in the join table
string $table2IdCol (line 77)
  • var: column name of ID column in the right table

Inherited Variables

Inherited from Field

Field::$attr
Field::$changed
Field::$DEBUG
Field::$defaultValue
Field::$description
Field::$duplicateName
Field::$editable
Field::$errorclass
Field::$hidden
Field::$isValid
Field::$isValidTest
Field::$longname
Field::$name
Field::$namebase
Field::$notifyIdChange
Field::$oob_errorMessage
Field::$oob_status
Field::$ovalue
Field::$required
Field::$requiredTwoStage
Field::$sqlHidden
Field::$suppressValidation
Field::$useNullValues
Field::$value
Field::$valueCleaner
Methods
Constructor JoinMatrix (line 111)

Create a new joinmatrix object

JoinMatrix JoinMatrix ( $joinTable, string $jtIdField, string $jtConstKeyCol, string $table1IdCol, string $table1, string $jtVarKeyCol, string $table2IdCol, string $table2, string $name, string $longname, [string $description = ''], string $jointable)
  • string $jointable: see $this->joinTable
  • string $jtIdField: (presently unused)
  • string $jtConstKeyCol: see $this->jtConstKeyCol
  • string $table1IdCol: see $this->table1IdCol
  • string $table1: see $this->table1
  • string $jtVarKeyCol: see $this->jtVarKeyCol
  • string $table2IdCol: see $this->table2IdCol
  • string $table2: see $this->table2
  • string $name: the name of the field (db name, and html field name
  • string $longname: used in the html label
  • string $description: used in the html title or longdesc for the field
  • $joinTable
addElement (line 192)

add a field to the join table

Field will appear in each row returned from the join table

void addElement (Field $field, string $groupValidTest)
  • Field $field: the field to be added
  • string $groupValidTest: data validation routine for this field
addKeys (line 145)

Add key Fields for the id columns in the left and right tables

void addKeys (Field $key1, Field $key2)
  • Field $key1: key field for left table (unused?)
  • Field $key2: key field for right table
display (line 227)
void display ()

Redefinition of:
Field::display()
Generic display function
displayInTable (line 266)
void displayInTable ([ $cols = 3])
  • $cols

Redefinition of:
Field::displayInTable()
render this form widget in an html table
idChange (line 349)

Change the Id value of each row

void idChange ( $newId)
  • $newId
isValid (line 338)

override the isValid method of the Field class, using the checkValid method of each member row completed as well as cross checks on other fields.

  • return: data is valid
boolean isValid ()

Redefinition of:
Field::isValid()
Check the validity of the current data value.
selectable (line 231)
void selectable ()

Redefinition of:
Field::selectable()
return an html representation of the widget
selectedValue (line 258)
void selectedValue ()

Redefinition of:
Field::selectedValue()
return the current value as text and the widget as a hidden form element
setEditable (line 368)

set whether each row is editable

void setEditable ([ $editable = false])
  • $editable

Redefinition of:
Field::setEditable()
set whether this field is editable or not
setKey (line 157)

set the id that this object will match in the left table

void setKey (integer $id)
  • integer $id: id from the left table to match
setNamebase (line 358)

Set the name base of the rows

void setNamebase ([ $namebase = ''])
  • $namebase

Redefinition of:
Field::setNamebase()
set the namebase for the data storage in the html form
sqlSetStr (line 306)

trip the complex field within us to sync(), which allows us to then know our actual value (at last).

void sqlSetStr ([$name $name = ''], [$force $force = false])
  • $name $name: (unused)
  • $force $force: (unused)

Redefinition of:
Field::sqlSetStr()
create an SQL-injection-cleansed string for db statements
update (line 281)
void update ( $data)
  • $data

Redefinition of:
Field::update()
update the value of the object with the user-supplied data in $data
_createRow (line 202)

Create a new row from the protorow for storing data

void _createRow (integer $rowNum)
  • integer $rowNum: number of this row (used as unique identifier in the namebase)
_fillFromProto (line 210)

Fill from the database one row at a time

void _fillFromProto ()
_joinSync (line 318)

synchronise the join table

void _joinSync ()
_populateList (line 168)

populates the matrix from the database

void _populateList ()

Inherited Methods

Inherited From Field

Field::Field()
Field::display()
Field::displayInTable()
Field::getValue()
Field::hidden()
Field::isValid()
Field::log()
Field::selectable()
Field::selectedValue()
Field::set()
Field::setattr()
Field::setEditable()
Field::setNamebase()
Field::sqlSetStr()
Field::text_dump()
Field::update()
Field::__clone()

Documentation generated on Tue, 06 Mar 2007 10:01:43 +0000 by phpDocumentor 1.3.0