ajaxCRUD.com

» a PHP class to create / read / update / delete from a database table using AJAX

   by loud canvas media

AjaxCRUD API Reference

<< Reference overview
<< Home

defineRelationship

defines a relationship between your table and another (via the foreign key)
void defineRelationship ( String dbMainTableFK, String dbOtherTable, String dbOtherTablePK, String dbOtherTableField [, String dbOtherTableSortField = "", int required = 1] )
This function sets the "allowable" values in a dropdown box for a 1-Many relationship. Your dropdown VALUE will be the foreign key and the option TEXT will be the field of your choosing in the associated table.

Details

Type function
Returns void

Parameters

dbMainTableFK
Foreign key of the main table
dbOtherTable
Name of the assocated table (table you're making a relationship to)
dbOtherTablePK
Primary key of the associated table (this is the VALUE of the dropdown)
dbOtherTableField
Field to return for the TEXT in the dropdown
(optional) dbOtherTableSortField
The name of the field in the associated table you wish to sort by (eg fldSort)
(optional) required
0 to make this field not require one of the choices (default) | 1 to require one be selected

Example

$tblDemo->defineRelationship("fkOtherTableID", "tblOtherTable", "pkOtherTableID", "fldOtherTableField");

See also

New, Edit

 

"just what i [was] look[ing] for..."
~Sergey