Create a Relationship Example
Consider the following tables (and SQL insert statements):
CREATE TABLE tblGenres(
pkGenreID INT PRIMARY KEY AUTO_INCREMENT,
fldGenre VARCHAR(40)
);
CREATE TABLE tblMyMp3CollectionDemo2(
pkMP3ID INT PRIMARY KEY AUTO_INCREMENT,
fldFilename VARCHAR(150),
fldTitle VARCHAR(60),
fldArtist VARCHAR(60),
fkGenreID INT
);
INSERT INTO tblGenres (fldGenre) VALUES ("Rock");
INSERT INTO tblGenres (fldGenre) VALUES ("Pop");
INSERT INTO tblGenres (fldGenre) VALUES ("Euro Trash");
INSERT INTO tblGenres (fldGenre) VALUES ("Sweedish HipHop");
| fldFilename | fldTitle | fldArtist | fkGenreID | Action |
|---|---|---|---|---|
| gu | kop | hu | Pop | |
| ghvguk | s | ;up;u; | Euro Trash | |
| asdsg | drgfdg | drfgdg | Rock | |
| -- | -- | -- | Rock |
Class Implementation:
#include the class
include ('ajaxCRUD.class.php');
#this one line of code is how you implement the class
$tblDemo = new ajaxCRUD(
"MP3 File", "tblMyMp3CollectionDemo2", "pkMP3ID");
$tblDemo->defineRelationship("fkGenreID", "tblGenres", "pkGenreID",
"fldGenre");
$tblDemo->omitPrimaryKey();
#actually show to the table
$tblDemo->showTable();
View Example by Itself
Click here to view example outside of the template.
Recent Feedback
Amigo" - Posted by Horacio from méxico on Tuesday Aug 12th, 2008 at 3:23pm
Are you still working on it?" - Posted by Omar on Monday May 11th, 2009 at 1:03am