[eluser]rideearthtom[/eluser]
Great library once again, I hate coming here because I've found something broken or not working as expected - sorry in advance! (This error occurs with 1.6.* as well.)
Here's my problem. DMZ is looking for a join table where there isn't one and doesn't need to be one.
Here are two related models, the first having a 0*M relationship with the second.
Code:
class Pe_style extends DataMapper {
var $prefix = 'projectexposure_';
var $table = 'styles';
var $has_many = array('pe_project_profile','pe_substyle','pe_roomtype');
function __construct($id = NULL)
{
parent::__construct($id);
}
}
Code:
class Pe_substyle extends DataMapper {
var $prefix = 'projectexposure_';
var $table = 'substyles';
var $has_many = array('pe_project_profile');
var $has_one = array('pe_style');
function __construct($id = NULL)
{
parent::__construct($id);
}
}
I'm setting custom table names and prefixes for this objects. This is necessary because the objects are coming from a database which is shared between two applications. I'm using a different prefix for each app, 'tdb_' for this one and 'projectexposure_' for the other, but there are some instances (like this) in which I need to work with objects that are native to the other app, so I'm setting the prefixes in the class declarations of the models for these objects.
'Pe_style' is the model name for a DB table 'projectexposure_styles', and 'Pe_substyle' is named by the same convention. The Pe_substyle table contains a column named 'style_id' to store the relationship. So far, so good, and this works fine in the second app in which the global table prefix is set to 'projectexposure_' and the models are named as per the tables (not needing a custom $table var).
SELECT `projectexposure_styles`.* FROM (`projectexposure_styles`) LEFT OUTER JOIN `tdb_join_styles_substyles` tdb_join_styles_substyles ON `projectexposure_styles`.`id` = `tdb_join_styles_substyles`.`pe_style_id` WHERE `tdb_join_styles_substyles`.`pe_substyle_id` = 1
Why is DMZ looking for a join table in a one-many relationship where an in-table FK exists?
I can get around it by creating the related object separately and fetching the instance with a where clause on the FK, but it's not the designed behaviour AFAIK.
Or maybe there are restrictions I wasn't aware of?