Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7877445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:22:23+00:00 2026-06-03T03:22:23+00:00

I’m trying to create a reference manually from one Model to another model, using

  • 0

I’m trying to create a reference manually from one Model to another model, using the example given in http://agiletoolkit.org/doc/modeltable/reference. I’m using the following tables and models:

Person Table

  • id: primary key
  • name: char
  • room_number: int
  • email: char

User Table

  • id: primary key
  • person_id: foreign key to Person Table (id)
  • password: char

The ATK4.2 classes are below:

Person Model

class Model_Person extends Model_Table {
public $entity_code='person';

function init(){
    parent::init();
    $this->addField('name');
    $this->addField('roomnumber');
    $this->addField('email');
}
}

User Model

The ‘user’ table contains the password field.

class Model_User extends Model_Table {
public $entity_code='user';

function init(){
    parent::init();

    $field_ref = $this->add('Field_Reference', 'person_id');
    $field_ref->dereferenced_field = 'person_str';
    // add referenced Model
    $m = $this->add('Model_Person');
    $m->addField('name');
    // Link referenced model field name to this model field.
    $field_ref->setModel($m, 'name');


}
}

However, I’m getting the following error, where the Model_Person class is being added using the wrong path, Model/Model/Person.php

PathFinder_Exception

Unable to include Model/Model/Person.php

Additional information:

    type: php
    attempted_locations: Array ( [0] => /var/www/html/seqtrack/admin/lib/Model/Model/Person.php [1] => /var/www/html/seqtrack/atk4/lib/Model/Model/Person.php [2] => /var/www/html/seqtrack/admin/../lib/Model/Model/Person.php [3] => /var/www/html/seqtrack/atk4/../atk4-addons/mvc/Model/Model/Person.php [4] => /var/www/html/seqtrack/atk4/../atk4-addons/misc/lib/Model/Model/Person.php ) 

/var/www/html/seqtrack/atk4/lib/BaseException.php:38
Stack trace:
/var/www/html/seqtrack/atk4/lib/BaseException.php   :38     PathFinder_Exception    PathFinder_Exception->collectBasicData(Null, 1, 0)
/var/www/html/seqtrack/atk4/lib/PathFinder.php  :213    PathFinder_Exception    PathFinder_Exception->__construct("Unable to include Model/Model/Person.php")
/var/www/html/seqtrack/atk4/lib/PathFinder.php  :131    PathFinder_Exception    PathFinder_Exception->__construct("php", "Model/Model/Person.php", Array(5))
/var/www/html/seqtrack/atk4/lib/PathFinder.php  :195    test_pathfinder PathFinder->locate("php", "Model/Model/Person.php", "path")
/var/www/html/seqtrack/atk4/lib/AbstractObject.php  :159    test_pathfinder PathFinder->loadClass("Model_Model_Person")
/var/www/html/seqtrack/atk4/lib/Field/Reference.php :89     test_mgr_tabs_view_htmlelement_crud_model_user_person_id    Field_Reference->add("Model_Model_Person")
/   :   test_mgr_tabs_view_htmlelement_crud_model_user_person_id    Field_Reference->calculateSubQuery(Object(Model_User), Object(DB_dsql_mysql), Object(Field_Expression))
/var/www/html/seqtrack/atk4/lib/Field/Expression.php    :44         Loggercall_user_func(Array(2), Object(Model_User), Object(DB_dsql_mysql), Object(Field_Expression))
/var/www/html/seqtrack/atk4/lib/Model/Table.php :169    test_mgr_tabs_view_htmlelement_crud_model_user_person_str   Field_Expression->updateSelectQuery(Object(DB_dsql_mysql))
/var/www/html/seqtrack/atk4/lib/Model/Table.php :327    test_mgr_tabs_view_htmlelement_crud_model_user  Model_User->selectQuery()
/var/www/html/seqtrack/atk4/lib/CompleteLister.php  :104    test_mgr_tabs_view_htmlelement_crud_model_user  Model_User->rewind()
/var/www/html/seqtrack/atk4/lib/Grid/Basic.php  :175    test_mgr_tabs_view_htmlelement_crud_grid    Grid->renderRows()
/var/www/html/seqtrack/atk4/lib/CompleteLister.php  :118    test_mgr_tabs_view_htmlelement_crud_grid    Grid->renderRows()
/var/www/html/seqtrack/atk4/lib/Grid/Advanced.php   :152    test_mgr_tabs_view_htmlelement_crud_grid    Grid->render()
/var/www/html/seqtrack/atk4/lib/AbstractView.php    :214    test_mgr_tabs_view_htmlelement_crud_grid    Grid->render()
/var/www/html/seqtrack/atk4/lib/AbstractView.php    :205    test_mgr_tabs_view_htmlelement_crud_grid    Grid->recursiveRender()
/var/www/html/seqtrack/atk4/lib/AbstractView.php    :205    test_mgr_tabs_view_htmlelement_crud CRUD->recursiveRender()
/var/www/html/seqtrack/atk4/lib/AbstractView.php    :205    test_mgr_tabs_view_htmlelement  View_HtmlElement->recursiveRender()
/var/www/html/seqtrack/atk4/lib/AbstractView.php    :205    test_mgr_tabs   Tabs->recursiveRender()
/var/www/html/seqtrack/atk4/lib/AbstractView.php    :205    test_mgr    page_mgr->recursiveRender()
/var/www/html/seqtrack/atk4/lib/ApiWeb.php  :236    test    AdminFrontend->recursiveRender()
/var/www/html/seqtrack/atk4/lib/ApiFrontend.php :123    test    AdminFrontend->execute()
/var/www/html/seqtrack/atk4/lib/ApiWeb.php  :226    test    AdminFrontend->execute()
/var/www/html/seqtrack/admin/index.php  :8  test    AdminFrontend->main()

A similar problem can be seen on the ATK DVD example web page:

http://example.agiletoolkit.org/examples/dvdrental/

PathFinder_Exception

Unable to include Model/Model/Customer.php

Additional information:

type: php
attempted_locations: Array ( [0] => /www/agiletoolkit.org/example/examples/dvdrental/lib/Model/Model/Customer.php [1] => /www/agiletoolkit.org/example/atk4/lib/Model/Model/Customer.php [2] => /www/agiletoolkit.org/example/atk4/../atk4-addons/mvc/Model/Model/Customer.php [3] => /www/agiletoolkit.org/example/atk4/../atk4-addons/misc/lib/Model/Model/Customer.php ) 

/www/agiletoolkit.org/example/atk4/lib/BaseException.php:38
Stack trace:
/www/agiletoolkit.org/example/atk4/lib/BaseException.php    :38     PathFinder_Exception    PathFinder_Exception->collectBasicData(Null, 1, 0)
/www/agiletoolkit.org/example/atk4/lib/PathFinder.php   :209    PathFinder_Exception    PathFinder_Exception->__construct("Unable to include Model/Model/Customer.php")
/www/agiletoolkit.org/example/atk4/lib/PathFinder.php   :134    PathFinder_Exception    PathFinder_Exception->__construct("php", "Model/Model/Customer.php", Array(4))
/www/agiletoolkit.org/example/atk4/lib/PathFinder.php   :195    Frontend_pathfinder PathFinder->locate("php", "Model/Model/Customer.php", "path")
/www/agiletoolkit.org/example/atk4/lib/AbstractObject.php   :158    Frontend_pathfinder PathFinder->loadClass("Model_Model_Customer")
/www/agiletoolkit.org/example/atk4/lib/AbstractController.php   :26     Frontend    Frontend->add("Model_Model_Customer")
/www/agiletoolkit.org/example/examples/dvdrental/lib/RentalAuth.php :5  Frontend_rentalauth RentalAuth->setModel("Model_Customer")
/www/agiletoolkit.org/example/atk4/lib/AbstractObject.php   :181    Frontend_rentalauth RentalAuth->init()
/www/agiletoolkit.org/example/examples/dvdrental/lib/Frontend.php   :21     Frontend    Frontend->add("RentalAuth")
/www/agiletoolkit.org/example/atk4/lib/ApiCLI.php   :48     Frontend    Frontend->init()
/www/agiletoolkit.org/example/atk4/lib/ApiWeb.php   :38     Frontend    Frontend->__construct(Null)
/www/agiletoolkit.org/example/examples/dvdrental/index.php  :3  Frontend    Frontend->__construct()

Cheers.


Update

The code fragment needs to go into the User class, so it now looks like this:

class Model_User extends Model_Table {
public $entity_code='user';

function init(){
    parent::init();

    $this->hasOne('Person');

    $field_ref = $this->getField('person')->rename('person_str');
    $this->getField('person_id')->dereferenced_field='person_str';

    // add referenced Model
    $m = $this->add('Model_Person');
    $m->addField('name');

    // Link referenced model field name to this model field.
    $field_ref->setModel($m, 'name');

}
}

The SQL produced is:

select id,person_id,(select name from person where user.person_id = person.id ) person_str from user


However the below class also produces the same SQL statemetn.

class Model_User extends Model_Table {
public $entity_code='user';

function init(){
    parent::init();

    $this->hasOne('Person');

    $this->getField('person')->rename('person_str');

}
}

So I don’t quite understand the function and need for the rest of the code:
$this->getField(‘person_id’)->dereferenced_field=’person_str’;

    // add referenced Model
    $m = $this->add('Model_Person');
    $m->addField('name');

    // Link referenced model field name to this model field.
    $field_ref->setModel($m, 'name');

I hope we can get some further explanation on this, thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:22:25+00:00Added an answer on June 3, 2026 at 3:22 am

    try this inside your person model

    $this->hasOne('Person');
    $this->getField('person')->rename('person_str');
    $this->getField('person_id')->dereferenced_field='person_str';
    

    otherwise “setmodel” is not working with pre-created objects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am reading a book about Javascript and jQuery and using one of the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.