ajaxCRUD.com

» a PHP class to Create, Read, Update, & Delete from a mysql database table using AJAX

   by loud canvas media

AjaxCRUD Class Documentation / Reference Material

<< 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 ], [String whereClause=""] )
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 associated 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
(optional) whereClause
a where clause for the associated table to use

Example

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

OR (w/advanced features)

$tblDemo->defineRelationship("fkOtherTableID", "tblOtherTable", "pkOtherTableID", "fldOtherTableField", "fldSort", 0, "WHERE fldOtherTableName LIKE 'Libertarian%'");

DISPLAY MORE THAN ONE FIELD:

$tblDemo->defineRelationship("fkOtherTableID", "tblOtherTable", "pkOtherTableID", "CONCAT(fldFirstName, " ", fldMiddleName, " ", fldLastName)")

See also

New, Edit

 

"Brilliant. Saved insane amounts of time. `nuff said."
~Soule

What is a business/commercial website?

A commercial website is one created for a business, for which purpose is generating revenue or cash flow of any type (and that isn't under a non-profit organization). So if you're selling a product, selling advertisement, selling a service, or just marketing a commercial business, your site is commercial. A company website is also commercial even if it doesn't sell anything, as it's purpose is to front a commercial company.
Close