08 on foreign key

  • Thread starter Michael Workman
  • Start date
M

Michael Workman

Guest
I am using databik 3.0 beta..

I have a simple table

CREATE TABLE `area` (
`area` varchar(35) NOT NULL default '',
`sort` tinyint(5) NOT NULL default '0',
PRIMARY KEY (`area`),
UNIQUE KEY `area` (`area`)
) TYPE=MyISAM;

that i am using to provide a drop down on the area field in this table:

CREATE TABLE `issue` (
`key` tinyint(5) NOT NULL auto_increment,
`area` varchar(35) NOT NULL default '',
`issue` varchar(35) NOT NULL default '',
`sort` tinyint(5) NOT NULL default '0',
PRIMARY KEY (`key`),
UNIQUE KEY `issue` (`issue`)
) TYPE=MyISAM AUTO_INCREMENT=33 ;

I defined in Dadabik via interface creator on the issue table as follows:

Primary key field ---- area
Primary key table ---- area
Linked fields ---- area


That seems to work as i want it to...in adding records...however...when i try to display the records via dadabik...it gives an error 08 and generates the SQL as follows.

SELECT `issue`.`key`, `issue`.`area`, `issue`.`issue`, `issue`.`sort`, `area`.`area` FROM issue LEFT JOIN `area` ON `issue`.`area` = `area`.`area` ORDER BY issue.key ASC LIMIT 0 , 10

I dont see what i have done wrong, Do YOU?

Thanks in advance for your help
 
R

Roger Beggs

Guest
I've noticed that foreign key queries are one place where the table name (issue in your case) is not quoted. I don't know if 'issue' is a reserved word, but I had the problem with 'option', which is.
This can be fixed by changing the line:
$sql .= " FROM ".$table_name;
to:
$sql .= " FROM ".$quote.$table_name.$quote;
near the end of business_logic.php
 
E

Eugenio

Guest
Michael Workman wrote:

> I am using databik 3.0 beta..
>
> I have a simple table
>
> CREATE TABLE `area` (
> `area` varchar(35) NOT NULL default '',
> `sort` tinyint(5) NOT NULL default '0',
> PRIMARY KEY (`area`),
> UNIQUE KEY `area` (`area`)
> ) TYPE=MyISAM;
>
> that i am using to provide a drop down on the area field in
> this table:
>
> CREATE TABLE `issue` (
> `key` tinyint(5) NOT NULL auto_increment,
> `area` varchar(35) NOT NULL default '',
> `issue` varchar(35) NOT NULL default '',
> `sort` tinyint(5) NOT NULL default '0',
> PRIMARY KEY (`key`),
> UNIQUE KEY `issue` (`issue`)
> ) TYPE=MyISAM AUTO_INCREMENT=33 ;
>
> I defined in Dadabik via interface creator on the issue table
> as follows:
>
> Primary key field ---- area
> Primary key table ---- area
> Linked fields ---- area

[....]

Your db structure is not very clear, you should have in the table "issue" an ID_area that link the same ID_area (primary key field) in the "area" table (primary key table) and an area description field (linked field) again in the "area" table.



(Latest version of DaDaBIK when this message was posted: 3.0 beta)
 
Top