Permalink
Browse files

Simple example counting number of tree nodes.

  • Loading branch information...
1 parent 4ef841f commit 631dbfd5402a050c394d88e1db0ed9c1a86e2b93 @mateu mateu committed Mar 5, 2009
Showing with 42 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +6 −0 README
  3. +34 −0 script/util/init_db_re.pl
View
@@ -12,3 +12,5 @@ t/var/mojomojo.db
t/var/upload
mojomojos.kpf
MojoMojo-*
+.includepath
+.project
View
6 README
@@ -0,0 +1,6 @@
+Installation: See INSTALL or lib/MojoMojo/Installation.pod
+
+After Installation: Run script/mojomojo_server.pl to test the application.
+
+License: This is free software. You can redistribute it and/or modify
+it under the same terms as perl itself.
View
@@ -0,0 +1,34 @@
+use strict;
+use warnings;
+use FindBin;
+use lib "$FindBin::Bin/../../lib";
+
+use MojoMojo::Schema;
+use base 'Exporter';
+our @EXPORT =
+ qw( $schema $preference_rs $page_rs @root_lower_family $root_page $number_of_family_members );
+
+# Make the dbi connection info MATCH YOUR ENVIRONMENT.
+our $schema =
+ MojoMojo::Schema->connect( 'dbi:mysql:database=mojomojo;host=localhost',
+ 'mojomojo', 'pass' );
+
+our $preference_rs = $schema->resultset('Preference');
+our $page_rs = $schema->resultset('Page');
+our $root_page = $page_rs->find( { id => 1 } );
+our @root_lower_family = $root_page->descendants;
+our $number_of_family_members = scalar @root_lower_family;
+
+__PACKAGE__->export_to_level(1);
+
+__END__
+
+=head1 Usage
+
+This code can be run within re.pl as:
+
+ do '$name_of_this_script'
+
+This will load the schema set the exported variables.
+
+=cut

0 comments on commit 631dbfd

Please sign in to comment.