Yii structure and PostgreSQL partitioned table - 0 rows affected

  • PostgreSQL 9.1
  • Split tables
    • tbl_master
    • tbl_slave1 (iherits master)
    • tbl_slave2 (iherits master)
  • Frame Yii 1.1.10

Maybe someone can digest their expropriation in a partitioned Yii + PostgreSQL table. The part of PostgreSQL with partitioned tables, checks, and triggers works fine, but I can't make Yii like these tables.

The problem is that when pasted into a partitioned table, PostgreSQL gives 0 rows affected , and I cannot figure out how to do this. The Yii model believes that the new record is not saved (but it is) and $Model->save(); returns false, so afterSave() does not work, etc.

All other methods like ->find() or ->findAll() work well. Even if I update the just saved throw yii record, everything is fine, and I also execute afterSave . The problem is only in the part ->save() . The update works because I only have a trigger when inserting new lines.

I use a trigger to split new data into tables. Perhaps I need to change the trigger so that postgres knows that I am sending new data to the slave not master table?

One more thing. I added the primary key to the master table, so Yii Model (CActiveRecord) does not throw errors in the table without pk. I know that the documentation does not offer this, but I started working this way. Just trying to give a big picture of my situation.

Thanks!

+6
source share
1 answer

You can try using the rules as an alternative. Since it overwrites the request, I expect it to return the correct number of rows affected. Although triggers are better in most cases, I think the rules are better to insert data into the main table and delete them again.

This is described in paragraph 5.9.5 on this manual page .

+1
source

Source: https://habr.com/ru/post/915398/


All Articles