Query does not return all registry data

1

The following query returns the correct record but missing items on its return.

$nota = $this->Nota->find('first', [
    'conditions' => ['id' => $numero,
        'serie' => $serie
    ]
]);

For example: When no error, returns the complete array

array {
    ["id"] => "1"
    ["nome"] => "nome"
    ["serie"] => "serie"
    ["texto"] => "texto"
}

When the error returns the incomplete array

array {
    ["id"] => "2"
    ["serie"] => "serie2"
    ["nome"] => "nome2"
}
    
asked by anonymous 19.12.2016 / 17:45

1 answer

2

If they are fields of the same model / table as you say, you can pass the list of fields you want. For example:

$nota = $this->Nota->find('first', [
    'fields' => ['id', 'nome', 'serie', 'texto'],
    'conditions' => ['id' => $numero,
        'serie' => $serie
    ]
]);

If they are fields from another model, you may not have defined the relationships correctly.

    
19.12.2016 / 17:59