Foreign keys are used to show relationships between tables in a database. If you had a database table for a Book object, you may also have a related table for Author. Each row in Book could then have a column with an AuthorID, that relates that Book to a row in the Author table. You can then add a foreign key to your database, that makes the relationship official. DABL will recognize foreign keys and create class methods for them that can be used as follows:



require_once('config.php');

//Retrieve Book with Primary Key(ID) of 34
$myBook = Book::retrieveByPK(34);

//Retrieve the Author of the Book
$author = $myBook->getAuther();

//Retrieve all the Books by that Author
$allBooks = $author->getBooks();

?>

In order for DABL to create foreign key methods, your tables must be setup using the MySQL InnoDB engine, rather than MyIsam.

(503) 746-9116 | 17933 NW Evergreen Parkway, Suite 220 | Beaverton, Oregon 97006