On May 25, 2012, at 10:02 AM, <gizmomathboy@gmail.com> wrote:
Is there a way to access multiple tables using SimpleCRUD without using foreign keys?
I have a relatively small database with a 3 tables or so but I don't have foreign keys between the tables.
I don't understand the motivation of the question. Having (or not) FKs has nothing to do with being able to query tables. Just make the appropriate JOINs and get going. FKs only allow you to pass the responsibility of ensuring data integrity to the database instead of coding it in the application. -- Puneet Kishor
On May 25, 2012, at 12:52 PM, <gizmomathboy@gmail.com> wrote:
On May 25, 2012 11:10 AM, Puneet Kishor <punk.kish@gmail.com> wrote:
On May 25, 2012, at 10:02 AM, <gizmomathboy@gmail.com> wrote:
Is there a way to access multiple tables using SimpleCRUD without using foreign keys?
I have a relatively small database with a 3 tables or so but I don't have foreign keys between the tables.
I don't understand the motivation of the question. Having (or not) FKs has nothing to do with being able to query tables. Just make the appropriate JOINs and get going. FKs only allow you to pass the responsibility of ensuring data integrity to the database instead of coding it in the application.
Using Dancer::Plugin::SimpleCRUD there doesn't seem to be a way (from reading the documentation or search around for examples) to access more than 1 table in the simple_crud() call. It does look like you can use FKs to pull them into that 1 table.
ahhh... I know nothing about that plugin. I tend to not use too much abstraction in my work as it only ends up confusing the heck out of me. If you have only 3 tables, you might do well to just hand code the darn thing. On the other hand, as the wise saying goes, "A week of figuring it out can save you a few hours of doing it." -- Puneet Kishor
On Fri, May 25, 2012 at 12:56 PM, Puneet Kishor <punk.kish@gmail.com> wrote:
On May 25, 2012, at 12:52 PM, <gizmomathboy@gmail.com> wrote:
On May 25, 2012 11:10 AM, Puneet Kishor <punk.kish@gmail.com> wrote: On May 25, 2012, at 10:02 AM, <gizmomathboy@gmail.com> wrote:
Is there a way to access multiple tables using SimpleCRUD without using foreign keys? I have a relatively small database with a 3 tables or so but I don't have foreign keys between the tables. Using Dancer::Plugin::SimpleCRUD there doesn't seem to be a way (from reading the documentation or search around for examples) to access more than 1 table in the simple_crud() call. It does look like you can use FKs to pull them into that 1 table.
What about using an SQL view to create a single virtual table to use with SimpleCRUD? http://www.w3schools.com/sql/sql_view.asp Chris
On Fri, 25 May 2012 11:02:00 -0400 <gizmomathboy@gmail.com> wrote:
Is there a way to access multiple tables using SimpleCRUD without using foreign keys?
I have a relatively small database with a 3 tables or so but I don't have foreign keys between the tables.
Not currently; I've been working on such abilities, but it's awaiting further tuits. The progress so far is in the feature/foreignkeys branch of the repo: https://github.com/bigpresh/Dancer-Plugin-SimpleCRUD Despite the name, it will work even if they are not designated as foreign keys in the database. It's fairly basic so far. I hope to have time to work on this module further soon, but I've been busy with various stuff lately which has taken time away from personal coding projects. -- David Precious ("bigpresh") <davidp@preshweb.co.uk> http://www.preshweb.co.uk/ www.preshweb.co.uk/twitter www.preshweb.co.uk/linkedin www.preshweb.co.uk/facebook www.preshweb.co.uk/cpan www.preshweb.co.uk/github
On 05/28/2012 05:07 AM, David Precious wrote:
On Fri, 25 May 2012 11:02:00 -0400 <gizmomathboy@gmail.com> wrote:
Is there a way to access multiple tables using SimpleCRUD without using foreign keys?
I have a relatively small database with a 3 tables or so but I don't have foreign keys between the tables.
Not currently; I've been working on such abilities, but it's awaiting further tuits. The progress so far is in the feature/foreignkeys branch of the repo:
https://github.com/bigpresh/Dancer-Plugin-SimpleCRUD
Despite the name, it will work even if they are not designated as foreign keys in the database.
It's fairly basic so far.
I hope to have time to work on this module further soon, but I've been busy with various stuff lately which has taken time away from personal coding projects.
I created a rather ugly hack to do what I need. --- SimpleCRUD.pm 2012-06-03 22:12:36.257043296 -0400 +++ SimpleCRUD-orig-with-gizmo.pm 2012-06-03 22:16:24.490175040 -0400 @@ -260,6 +260,18 @@ sub simple_crud { my (%args) = @_; + if ( exists $args{prefix} ) { + _create_simple_crud_routes(%args); + } + else { + for my $args ( @_ ) { + _create_simple_crud_routes(%$args); + } + } +} + +sub _create_simple_crud_routes { + my (%args) = @_; # Get a database connection to verify that the table name is OK, etc. my $dbh = database($args{db_connection_name}); The call goes from: simple_crud ( prefix => '/table1', record_title => 'Table1', db_table => 'table1', ); to simple_crud ( { prefix => '/table1', record_title => 'Table1', db_table => 'table1', }, { prefix => '/table2', record_title => 'Table2', db_table => 'table2', }, ); Yeah, ugly. Now to do a pull request and look at that branch... gizmo
participants (5)
-
Christopher Taranto -
David Precious -
gizmo mathboy -
gizmomathboy@gmail.com -
Puneet Kishor