Editor - PHP Backend - set getValue from another column

Editor - PHP Backend - set getValue from another column

hapihapi Posts: 17Questions: 3Answers: 0

Hi, I am using php backend for Editor. I have a table with a CLOB. CLOBs are not supported. Hence I am trying to read and write the CLOB separately.

My table columns:

In Fileds I have defined only the ID and TEXT.

All works fine.

Can I now use for Field TEXT a formatter and read from TEXT_CLOB with my own DB query? My problem is, that the getFormatter dos not know which row is processed. I would need the ID, then I can read from TEXT_CLOB and return that value.

Same I would need for setValue.

In alternative I was trying to do this in ->on('postGet', but as far as I can see, I cannot modify here the data wich will be returned to the client. Same for ->on('beforeUpdate' etc., Can I modify the data before it is used to update the DB?

This question has an accepted answers - jump to answer


  • rf1234rf1234 Posts: 2,627Questions: 80Answers: 379
    Answer ✓

    The sky is the limit! PostGet is great to manipulate data. Just pass it by reference.


  • hapihapi Posts: 17Questions: 3Answers: 0

    Hi, many thanks for the hint. by reference was the key.

    However not an easy task (for me). My problem was, that on pre/post Create/Edit, the data is not yet commit by editor. To realize this, took me some time. I can't update the row if INSERT is not commit and I can't update if another UPDATE is not commit.

    However finally I managed to do it.
    * on preCreate/Edit I change the data to fit TEXT column, I remember the long TEXT
    * on postCreate/Edit I remember the ID (primary key) in a global variable
    * once editor's process is completed (after ->json();) I check if there is something in the ID and I update TEXT_CLOB for the given ID with my own db connection.

    Indeed, the limit is the sky. o:)

  • hapihapi Posts: 17Questions: 3Answers: 0

    Just one more finding on CLOB reading. In such cases the $val is a resource (stream), and the ->load() function will load it as a string. The load() function comes from the oracle library providing the database connection.

            Field::inst( 'CLOB_COLUMN' )
                ->getFormatter( function ( $val ) {
                    return $val->load();
                } ),

    It could be that easy... :smiley:

Sign In or Register to comment.