Simple List Example
Posted: Sat Jul 09, 2011 1:03 pm
I've had quick success getting Xataface setup to perform simple data entry against a new mysql database. But I'm having trouble understanding how to do many to many relationships without manually having to remember and enter numbers. While I've read the documentation, I must not be understanding it because my interpretation of the directions don't work. And I'm frustrated that the downloadable examples don't work for me either. So suppose I have the following
CREATE TABLE art
(
id INT NOT NULL AUTO_INCREMENT,
title VARCHAR(30),
artist_id
PRIMARY KEY (id)
) TYPE = INNODB;
and
create TABLE artist
(
id INT NOT NULL AUTO_INCREMENT,
lastname VARCHAR(30),
PRIMARY KEY(id)
) TYPE = INNODB;
I already have the application accepting artists names. But how to make the artist_id field populated from a pull down list of names from artist?
So it seems that I need to make some directories and files:
{webapp root}/tables/art/fields.ini
{webapp root}/tables/art/relationships.ini
In fields.ini, I can put things like
[title]
widget:label = "Title"
widget:description = "Enter the common name for this work."
and that works. It seems that I should encode the relationship between the two tables in art/relationships.ini? or artist/relationship.ini using the __sql__ entry on the first line (not in any kind of a section). But what should this sql say? http://xataface.com/wiki/relationships.ini_file doesn't give any kind of examples. The multimedia web application doesn't appear to have any relationships.ini files.
Looking at the web auction files, it looks like I should say
[artist]
__sql__ = "select * from artist where art_id='$art_id'"
in the tables/art/relationships.ini file
but this does nothing? Is this incorrect? Or is it incomplete? Clearly I am missing something. artist_id remains a text entry box instead of a list.
Thanks for any and all help.
CREATE TABLE art
(
id INT NOT NULL AUTO_INCREMENT,
title VARCHAR(30),
artist_id
PRIMARY KEY (id)
) TYPE = INNODB;
and
create TABLE artist
(
id INT NOT NULL AUTO_INCREMENT,
lastname VARCHAR(30),
PRIMARY KEY(id)
) TYPE = INNODB;
I already have the application accepting artists names. But how to make the artist_id field populated from a pull down list of names from artist?
So it seems that I need to make some directories and files:
{webapp root}/tables/art/fields.ini
{webapp root}/tables/art/relationships.ini
In fields.ini, I can put things like
[title]
widget:label = "Title"
widget:description = "Enter the common name for this work."
and that works. It seems that I should encode the relationship between the two tables in art/relationships.ini? or artist/relationship.ini using the __sql__ entry on the first line (not in any kind of a section). But what should this sql say? http://xataface.com/wiki/relationships.ini_file doesn't give any kind of examples. The multimedia web application doesn't appear to have any relationships.ini files.
Looking at the web auction files, it looks like I should say
[artist]
__sql__ = "select * from artist where art_id='$art_id'"
in the tables/art/relationships.ini file
but this does nothing? Is this incorrect? Or is it incomplete? Clearly I am missing something. artist_id remains a text entry box instead of a list.
Thanks for any and all help.