You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Joshua Spoerri <jo...@yucs.org> on 2003/02/18 21:48:28 UTC

TabRelation and inserts

What does everyone think about allowing special handling of !Table and
!TabRelation for inserts? For example, ignoring all but the first table?
Or maybe even performing a separate insert for each table?

I'm implementing permissions with a bridge table (between users and
resources), and would like to use a _single dbix object_ for each
resource, for both reading and writing.

The later 4.0 releases of mysql allow multi-table updates, but not
multi-table inserts. Would it be more appropriate for multi-table inserts
to be implemented in the database? To be at all useful, it would probably
be too nontraditional (imagine "insert into x, y (x.a, y.b) values (1, 2)
where x.id = y.x_id;" where x.id is an auto incremented key).
And besides, in dbix::recordset, the feature could be configured to work
for both inserts and updates, for databases that don't even support
multi-tables updates.

Here's an example of what I'm talking about:
$resource = DBIx::Recordset(
	'!Table'=>'resource, permission',
	'!TabRelation'=>'resource.id = perm.resource_id'
);
$resource->Search({resource_field=>$whatever,permission_field=>$mypermission});
#but also:
$resource->Insert(\%new_resource);
#and it would be nice if the following could be done by the preceding:
$permission->Insert({%new_permission,resource_id=>$resource->LastSerial});

Thanks in advance,
Joshua Spoerri


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: TabRelation and inserts

Posted by Gerald Richter <ri...@ecos.de>.

> What does everyone think about allowing special handling of !Table and
> !TabRelation for inserts? For example, ignoring all but the first table?
> Or maybe even performing a separate insert for each table?
>

My idea always was to do two inserts in this case, but I never got the time
to implement it. (feel free to do so :-)

Gerald



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org