Note that there are some explanatory texts on larger screens.

plurals
  1. PODBIx::Class::ResultSource::_resolve_join(): No such relationship
    text
    copied!<pre><code>use lib '/var/www/Employees'; use DBConnect::DBConnect qw(getSchemaConnection); BEGIN { $ENV{DBIC_TRACE} = 1 } $schema = getSchemaConnection(); $salaries = $schema-&gt;resultset('Salary')-&gt;search( { 'employees.emp_no'=&gt;100000 }, { join =&gt;'employees' } ); print $emplyees-&gt;count; </code></pre> <p>I have two tables employees and salary and Salary is belongs_to employees i like to search the salary with employee number which is in employees table</p> <p>when i try to run it i get the following error </p> <pre><code>DBIx::Class::ResultSource::_resolve_join(): No such relationship employees on Salary at /var/www/Employees/Testing/3_simpleJoin.pl line 29 </code></pre> <p>here are my calsses :</p> <p>Salary:</p> <pre><code>package DAO::Schema::Result::Salary; # Created by DBIx::Class::Schema::Loader # DO NOT MODIFY THE FIRST PART OF THIS FILE use strict; use warnings; use base 'DBIx::Class::Core'; __PACKAGE__-&gt;add_columns( "emp_no", { data_type =&gt; "integer", is_foreign_key =&gt; 1, is_nullable =&gt; 0 }, "salary", { data_type =&gt; "integer", is_nullable =&gt; 0 }, "from_date", { data_type =&gt; "date", datetime_undef_if_invalid =&gt; 1, is_nullable =&gt; 0 }, "to_date", { data_type =&gt; "date", datetime_undef_if_invalid =&gt; 1, is_nullable =&gt; 0 }, ); __PACKAGE__-&gt;set_primary_key("emp_no", "from_date"); __PACKAGE__-&gt;belongs_to( "emp_no", "DAO::Schema::Result::Employee", { emp_no =&gt; "emp_no" }, { is_deferrable =&gt; 1, on_delete =&gt; "CASCADE", on_update =&gt; "CASCADE" }, ); 1; </code></pre> <p>here is my Employee class</p> <pre><code>package DAO::Schema::Result::Employee; # Created by DBIx::Class::Schema::Loader # DO NOT MODIFY THE FIRST PART OF THIS FILE use strict; use warnings; use base 'DBIx::Class::Core'; __PACKAGE__-&gt;add_columns( "emp_no", { data_type =&gt; "integer", is_nullable =&gt; 0 }, "birth_date", { data_type =&gt; "date", datetime_undef_if_invalid =&gt; 1, is_nullable =&gt; 0 }, "first_name", { data_type =&gt; "varchar", is_nullable =&gt; 0, size =&gt; 14 }, "last_name", { data_type =&gt; "varchar", is_nullable =&gt; 0, size =&gt; 16 }, "gender", { data_type =&gt; "enum", extra =&gt; { list =&gt; ["M", "F"] }, is_nullable =&gt; 0 }, "hire_date", { data_type =&gt; "date", datetime_undef_if_invalid =&gt; 1, is_nullable =&gt; 0 }, ); __PACKAGE__-&gt;set_primary_key("emp_no"); __PACKAGE__-&gt;has_many( "salaries", "DAO::Schema::Result::Salary", { "foreign.emp_no" =&gt; "self.emp_no" }, { cascade_copy =&gt; 0, cascade_delete =&gt; 0 }, ); __PACKAGE__-&gt;has_many( "titles", "DAO::Schema::Result::Title", { "foreign.emp_no" =&gt; "self.emp_no" }, { cascade_copy =&gt; 0, cascade_delete =&gt; 0 }, ); 1; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload