0

I've an existing project in Code Igniter with HMVC extension. Also using php-activerecord through sparc.

For a new module, I created two tables with one-to-many relationship, enforced directly at DB level (in MySQL). Tables are say 'nassignment' (PK id) and 'nassignment_assignee' (FK assignment_id).

Under models, I created two class 'nassignment.php' having class Nassignment and 'nassignment_assignee.php' with class name Nassignment_assignee.

Below is the code I'm trying in controller

$this->load->model("nassignment");
$nAssignmentArr = $this->nassignment->all();

and getting following error

[Fri Aug 02 13:50:52 2013] [error] [client 127.0.0.1] PHP Fatal error:  Uncaught 
exception 'ReflectionException' with message 'Class Nassignmentassignee does not exist' 
in /home/kapil/projects/<project>/application/sparks/php-activerecord/0.0.2/vendor/php-
activerecord/lib/Reflections.php:33\nStack trace:\n#0 
/home/kapil/projects/<project>/application/sparks/php-activerecord/0.0.2/vendor/php-
activerecord/lib/Reflections.php(33): ReflectionClass-
>__construct('Nassignmentassi...')\n#1 
/home/kapil/projects/<project>/application/sparks/php-activerecord/0.0.2/vendor/php-
activerecord/lib/Relationship.php(286): ActiveRecord\\Reflections-
>add('Nassignmentassi...')\n#2 /home/kapil/projects/<project>/application/sparks/php-
activerecord/0.0.2/vendor/php-activerecord/lib/Relationship.php(281): 
ActiveRecord\\AbstractRelationship->set_class_name('Nassignmentassi...')\n#3 
/home/kapil/projects/<project>/application/sparks/php-activerecord/0.0.2/vendor/php-
activerecord/lib/Relationship.php(464): ActiveRecord\\AbstractRelationship-
>set_inferred_class_name()\n#4 /home/kapil/projects/<project>/application/sparks/php-
activerecord/0.0 in /home/kapil/projects/<project>/application/sparks/php-
activerecord/0.0.2/vendor/php-activerecord/lib/Reflections.php on line 33

Model code is

nassignment.php

class Nassignment Extends ActiveRecord\Model{
    static $table_name = 'nassignment';
    //Work fine if I remove following line, but do not get data
    static $has_many = array(
            array('nassignment_assignee')
        );
}

nassignment_assignee.php

class Nassignment_assignee Extends ActiveRecord\Model{
    static $table_name = 'nassignment_assignee';
}

Any suggesations, why it is not working

Kapil Sharma
  • 10,135
  • 8
  • 37
  • 66
  • I think I may have a similar problem [here](http://stackoverflow.com/questions/19075807/codeigniter-on-1and1-error-reporting). Why is no one attempting these questions? – Igbanam Oct 08 '13 at 03:20

1 Answers1

1

Try making sure that the name of the file matches the name of the class in case also. See the solution to my issue

Apparently, libraries too have to be named accordind to the UCfirst naming convention.

Community
  • 1
  • 1
Igbanam
  • 5,904
  • 5
  • 44
  • 68