typo3 - Referential Integrity in List View -


i have made extension in typo3 v4.5 extension builder. have tables, don't have create/update function, because don't change (only once in month). change them, want use list view in typo3.

that works, can create , update records. if have record, that's in relation other record, can delete it. other record has invalid value.

for example:

books _________________________ | name        | authorid | ------------------------- |harry potter | 1        | -------------------------  author _________________________ | id | name              | ------------------------- | 1  | rowling           | ------------------------- 

now if delete rowling, have "invalid value" in authorid field. can prevent this?

edit: okay, i've found way how prevent this: have use predb hook in tce extension. code (only experimenting) not work if delete record. thought i'll array element named 'deleted' value 1. not appear. other data (if alter information or make new record) appears.

    /**      * @param string $status      * @param string $table      * @param int $id      * @param array $fieldarray      * @param tce_main $tcemain      */     function processdatamap_postprocessfieldarray($status, $table, $id, &$fieldarray, &$tcemain) {         $fp = fopen('../../typo3conf/ext/test/hooks/output.txt', 'w');         ($x = 0; $x < sizeof($fieldarray); ++$x)         {              fwrite($fp, "key: ".key($fieldarray)."\tvalue: ".current($fieldarray)."\n");              next($fieldarray);         }         fclose($fp);     } 

edit2: in comments in first answer, can use status == delete check if typo3 going delete record. how prevent this, if can't change data in deleted attribute (because isn't in fieldarray)? clue?

thanks responses agash thamo.

you can overwrite delete method in repository , check if there reference other objects.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -