Active row is read only – again

4 years ago

jik
Member | 137
+
0
-

Hi,
after a year I open this question again. I have a high complexity data. I use data from table, from referenced table and ‘computed’ data. When I use Nette 2.0 I used possibility to add a item and change the ActiveRow, but it is not possible now.
I solved it using complicated models, for instance:

public function getPozemek ($id) {
    return $this->findAll()->select("pozemek.id, lv_id, process_id, process.icon AS icon, evidence, rada, cislo, podlomeni, dil, vymera, druhnem.nazev AS druhnem, druhnem.vyuziti AS vyuziti, msg, ...
            CASE WHEN rada>1 THEN ? ELSE '' END || CASE WHEN podlomeni>0 THEN cislo||'/'||podlomeni ELSE cislo||'' END AS pc", 'St.')
        ->where('pozemek.id',$id)->fetch();
}

but this is the way to the hell. Now I find alternative, but every ways have similar problems. Probably I'll remove ‘computed items’ from SQL query and move it into model, because when I use method select(), I cannot use referencing into another tables and I must every referenced column write into model.
I understand, that ActiveRow represent the data from table, but additioned items are also only data from table, only in ‘transformed’ form. It would be perfect to have a chance to add item to ActiveRow.

4 years ago

enumag
Member | 2128
+
0
-

Actually this looks like something I would do in the template, not in the model. Maybe as a {define} block if used many times.