1

I'm having a very strange issue. I'm working with XAMPP on my local computer, and everything works perfect. But when I upload it to my server, suddenly ContainableBehavior stops recognizing associations.

Cake's version: 2.5.6

Here's XAMPP's phpinfo(): http://pastebin.com/DeZWMh42

And here's my server's phpinfo(): http://pastebin.com/rtZ0kTAM

Both locations have the exact same files and databases.

This is the error(s) I'm getting:

Warning (512): Model "Certificado" is not associated with model "Usuario" [CORE/Cake/Model/Behavior/ContainableBehavior.php, line 342]

Warning (512): Model "Certificado" is not associated with model "Alumno" [CORE/Cake/Model/Behavior/ContainableBehavior.php, line 342]

Warning (512): Model "Certificado" is not associated with model "Usuario" [CORE/Cake/Model/Behavior/ContainableBehavior.php, line 342]

Warning (512): Model "Certificado" is not associated with model "Alumno" [CORE/Cake/Model/Behavior/ContainableBehavior.php, line 342]

Basically, an Impresion belongs to an Usuario and to a Certificado, the latter also belongs to an Usuario (may be a different one) and to an Alumno. Obviously I cut out all the irrelevant parts (let me know if you need more.)

This is where I'm using ContainableBehavior (Impresion's Controller):
(I'm getting the error on /impresions/index)

class ImpresionsController extends AppController {
    public $components = array('Paginator');
    public $uses = array('Usuario', 'Alumno', 'Certificado', 'Impresion');

    public function index(){

        $this->paginate = array(
            'limit' => 10,
            'order' => array('fecha_creacion' => 'desc'), 
                'contain'=>array(
                   'Usuario',
                   'Certificado' => array(
                      'Usuario',
                      'Alumno'
                   )
                ),
        );
        $results = $this->paginate('Impresion');
        $this->set('impresiones',$results);
    }
}

And in the view I just use a foreach($impresiones).

Impresion's Model:

class Impresion extends AppModel {
    public $actsAs = array('Containable');
    public $belongsTo = array(
            'Certificado' => array(
                'className' => 'certificado',
                'foreignKey' => 'certificado_id',
            ),
            'Usuario' => array(
                'className' => 'Usuario',
                'foreignKey' => 'usuario_id',
                'fields' => array('nombre','codigo')
            ),
        );
}

Usuario's Model:

class Usuario extends AppModel {
    public $hasMany = array('Certificado','Impresion');
    public $actsAs = array('Containable');
}

Certificado's Model:

class Certificado extends AppModel {
    public $actsAs = array('Containable');
    public $belongsTo = array(
        'Usuario' => array(
            'className' => 'Usuario',
            'foreignKey' => 'usuario_id',
        ),
        'Alumno' => array(
            'className' => 'Alumno',
            'foreignKey' => 'alumno_id',
        )
    );
    public $hasMany = 'Impresion';
}

Alumno's Model:

class Alumno extends AppModel {
        public $actsAs = array('Containable');
        public $hasMany = 'Certificado';
}

Local query: http://pastebin.com/B5MRp3FS

Server's query: http://pastebin.com/J2H4U6Ge

I'm completely lost here. Why does it work perfectly fine on my computer, but breaks on the server? Everything else works, it's just ContainableBehavior that's having problems.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • 1
    A very well formatted and posed question, rather unusual for the [php] tag! Hope to see you asking more questions here. I've rolled back the answer edit - as you guessed, answers belong below the line. To mark it as answered correctly, you may (and are encouraged to) click the tick mark to the left of the question. – halfer Jan 26 '15 at 15:29
  • 1
    Thank you! I tried to be as specific and thorough as possible since it was such a strange problem. Well, not really, I should've imagined that it had something to do with windows/linux case differences, but I was thinking about php config/version differences. Anyway, I'll mark the question as answered as soon as it lets me (it says that I need to wait 2 days.) I use stackoverflow quite regularly, but I never needed to ask a question since I always found the answer here first! Great site. I'll try to answer some questions though! – Franco Stramucci Jan 26 '15 at 15:35

1 Answers1

1

I can't believe it.

Disregard everything.

This:

'className' => 'certificado',

Should've been this:

'className' => 'Certificado',

Sorry for wasting your time, I'm an idiot