Not signed in (Sign In)
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    • CommentAuthormsalhab
    • CommentTimeMar 8th 2008
     

    I have a table called 'employee' which contains an attribute 'mgr_id' manager is also an employee

    I want to add an employee to some manager.

    I have define in Employee class like

    class Employee extends Acti....{

    var $belongs_to = array('employee'); var $has_many = array('employees');

    }

    when trying to make some operation like listing employees for such manager I got this error page:


    Notice: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1' at line 1 in C:\xampp\htdocs\akelos\lib\AkActiveRecord.php on line 1194

    Tasks:

    Fatal error: Call to a member function getId() on a non-object in C:\xampp\projects\hr\app\views\employee\compiled\show.tpl.php on line 4

    •  
      CommentAuthorriffed
    • CommentTimeMar 9th 2008
     

    Look at http://wiki.akelos.org/display-acts-as-tree-recursively?s=parent

    • CommentAuthorsuthern
    • CommentTimeMar 10th 2008
     

    What about setting a different foreign key (besides the primary id)?

    Here's my short create table statement with comments $this->createTable('customers', 'id,'. // Primary KEY 'ListID,'. // ListID from QB 'Name,'. // Name from QB 'FullName,'. // Full Name "Joe Smith" or "Joe Smith:Remodel" from QB 'ParentRefListID,'. // ListID of parent. (also from QB) ); Currently I have the following inside my model (customer.php) var $acts_as = array('tree' => array('parent_column' => 'ParentRefListID')); Any ideas?

    • CommentAuthorsuthern
    • CommentTimeMar 10th 2008 edited
     

    Hmm, according to AkActsAsTree.php, it' wouldn't be possible without a little bit of modification. 'ActiveRecordInstance->getId()' is hardcoded. See rows 263 and 268. return $this->_ActiveRecordInstance->isNewRecord() ? false : $this->_ActiveRecordInstance->findAll(" ".$this->getScopeCondition()." AND ".$this->getParentColumnName()." = ".$this->_ActiveRecordInstance->getId());

    Perhaps this could be stuck on the wishlist then. For now I'll use the ListID as the primary key.

Add your comments
    Username Password
  • Format comments as