Mlam main page

SourceForge Logo

Little note from the redactor, my natural language is french, so i apologize for the probable incoherences in this text
Want to see mlam working ? - external keys

Back

Preparation work
Before beginning working with the external keys, we have a new structure to create for the zones of our dvd. The creation process is exactly the same as in the first structure creation. Here's the finished structure :

Current table : zone, Primary key : zone_id   Edit the listing of these data
You can change the current name of the structure You can specify the number of rows
You can specify the number of rows
Field nameInformationsEdition ?Just show ?OrderActionOption(s)
zone
What title ?
 Insertion ?
Update ?
Max display length (in characters)
Do you want this value to be used as password type ?
Or you can use it as a file or picture data
zone_idPrimary key, not editable  
We need of course to list these data :


Name of the file to edit the data :
Field nameShown ?OrderUnder what name ?Ordered ?Order for sortingSearch it ?Under what name ?
zone
zone_id
And we have to create the file edit_zone.php (same directory as edit_movie.php) :
<?session_start();?>
<html>
<head>
<META HTTP-EQUIV="expires" CONTENT="0">
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
</head>
<body>
<a href="edit_zone.php?id=-1">Zone creation</a><br>
<a href="edit_zone.php">Zone listing</a><br>
<form method=post enctype="multipart/form-data" action='edit_zone.php'>
<?
require("mlam_tables_def.php");
mlam_form("edit_zone",$id);
?>
<input type=submit>
</form>
</body>
</html>
Before going to the next step, enter some values in this table, else your tests won't be very interesting. In my case, the listing of the zones looks like this :
    Number of results found : 7 (0-10)    
dvd zones
Zone 1
Zone 2
Zone 3
Zone 4
Zone 5
Zone 6
Zone all

Simple external key
We are going to create a structure for editing our dvds. In mlam's administration, select the dvd table, which looks very poor (only three fields including the primary key). We are going to name this structure edit_dvd, and we will edit two fields, comment and dvd_film_id, but for this one we will select the use this data as external key option, because we want it to represent the movie on the dvd. After adding this structure in your config, a new link will appear, just the same way it worked when using pictures. Click on create your configuration. You have this screen :
What table do you want to link??

Select film, this is the data we want to use here. The new screen is a little bit complicated :
What table do you want to link??


film : Choose your options (* means obligatory)
Type of link*
Your external key*
Data to show*
Row used for ordering data
Row for the father id (only for hierarchical selection)
Size (for select)
File name (only for picture selection)*
directory url (after http://www.yoursite.com)
(only for picture selection)*
directory (only for selectpic)*
We won't use all these options (you'll have to read the detailed documentation if you want to know what's all this). In fact, we will only use the obligatory data, so here we go :
- type of link : we could use a simple select type, but the list of the available movies may become huge, so we will use something more adapted to our contest : searching tool for selection.
- your external key : mlam needs some improvement here. Even if it tries to be smart, it still doesn't know for sure what's the primary key in the external table (film in our case), so we select here film_id.
- data to show : the title of the movie is evidently the data we want to use.
Validate your changes. Because of our search tool selection, some warnings appear, and the options are not completely the same :
film : Choose your options (* means obligatory)
Type of link*
Your external key*
Structure to edit new data
Current search options
Add search rows
Title : Row :
Current result options
Add result rows
Title : Row :
When using this option, a search tool will be available when editing a dvd to find its correct title. So we have to decide on which field to search, what fields to show as result, and more, because we have also the possibility to edit directly a new data if we don't find what we're looking for. So here we go :
- structure to edit new data : we will use edit_film in our case (our original structure to edit the movies).
- add search rows : we may use more than one row, but will do it simple here, so we will just use the title row (put everything you want for the title).
- add result rows : why not using the title and the year ? We just have to validate the title first (for instance), and then we have the possibility to add the year.
So we have now :
film : Choose your options (* means obligatory)
Type of link*
Your external key*
Structure to edit new data
Current search options
Title : Row : Delete ?
Add search rows
Title : Row :
Current result options
Title : Row : Delete ?
Title : Row : Delete ?
Add result rows
Title : Row :
Ok, now go back to the main page, add the current structure to the config and finally save your changes.

Our external key in action
We don't have here the possibility to list the dvds with names or things like that. Mlam doesn't know how to use an external key in a listing process (maybe later, who knows), but we will still list the dvd using the ids. It will be faster. So create your listing options, and edit a new file called edit_dvd.php :
<?session_start();?>
<html>
<head>
<META HTTP-EQUIV="expires" CONTENT="0">
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
</head>
<body>
<a href="edit_dvd.php?id=-1">Dvd creation</a><br>
<a href="edit_dvd.php">Dvd listing</a><br>
<form method=post enctype="multipart/form-data" action='edit_dvd.php'>
<?
require("mlam_tables_def.php");
mlam_form("edit_dvd",$id);
?>
<input type=submit>
</form>
</body>
</html>
I hope you have at least one movie in your database now, because it will be interesting.
Now open the url of edit_dvd.php, whose content is empty for the moment, and click on Dvd creation. You have something like this :
Movie name Need validation of the current data first
Comment
You have to validate your current dvd at least one time to have somthing new, so we'll create something new with a comment and then :
Insertion successful

Movie name Movie title :
Year of release :
Look for title
Comment
You DO have your search engin, so use it. In my case, I only have two movies in my database, so I'll simply look for a letter to have the two matches. I then have :
Results for n
Number of results found : 2

Selection Movie titleYear of release
james bond1974
nausicaa1984
Click here to go to the previous page Click here to create a new choice
If I select james bond and validate, the result is :
Movie name Movie title : james bond
Year of release : 1974
Look for title
Comment
And that's it... If you select the option to create a new choice, you'll be redirected to the same screen you created to edit your movies. After creation of the missing movie, a new option will appear :
Click to here to validate the data in the previous screen
Select it, validate the data, and here it is, the new has been linked to your dvd !

It's time now to have the possibility to use the zone table in your administration tool. Let's edit the multi link table