2

I have 2 models from tables I need to relate, campus:

class Campus extends Datamapper {

    var $table='campi';
    var $has_many=array('boleto');    

    function __construct()  {
        parent::__construct();  
    }
}

And boleto:

class Boleto extends Datamapper {

    var $table='boletos';
    var $has_one=array('campus');  

    function __construct(){
        parent::__construct();
    } 
}

I have been working with these tables 5 months, even have the relation table:

| id | boleto_id | campus_id |

Everything was ok, but recently, every time I need to make something that includes that relation I got this error message:

DataMapper Error: 'boleto' is not a valid parent relationship for Campus. Are your relationships configured correctly?

Do somebody know what's happening? I can't find the error. The strange is that, as I said, it was working.

Thanks in advance!

Table boletos:

| id | folio |

Table campi:

| id | nombre_campus |

Table boletos_campi:

| id | boleto_id | campus_id |

I'm trying with this code (as it was working before I already have the relation saved):

$b = new Boleto();
$b->where('id',20114)->get();
$b->campus->get();
Hashem Qolami
  • 97,268
  • 26
  • 150
  • 164
Laura
  • 21
  • 3
  • Can you show us that line where the error generating relation usage occurs? Also, the two table schema in question (boletos, campi) could be helpful too. You can just edit the question and add those too. – complex857 Aug 07 '13 at 18:24
  • The error comes in `$b->campus->get();` . – Laura Aug 07 '13 at 18:41
  • This is strange, i can't seem to reproduce the problem with these snippets, it's just generates a query like: `SELECT \`campi\`.* FROM (\`campi\`) LEFT OUTER JOIN \`boletos_campi\` boletos_campi ON \`campi\`.\`id\` = \`boletos_campi\`.\`campus_id\` WHERE \`boletos_campi\`.\`boleto_id\` = 1`. I would try to identify the change that broke the stuff, reading back on commit diffs can help. – complex857 Aug 07 '13 at 19:03
  • 1
    The problem is that it was working 5 months, I didn't change anything, and now it does not work :/ Thanks!! – Laura Aug 07 '13 at 19:08

0 Answers0