Datatables Editor PHP postCreate event

Datatables Editor PHP postCreate event

obrienjobrienj Posts: 93Questions: 38Answers: 0

I have the need to insert a series of rows in this event based upon the row that was just inserted but with a few column value changes.

I plan on using "$editor->$db()->Insert(....) to do this.

Am I better off using the content of $value or $row as a basis of the new row?

In either case, can you point me to an example?

Refgards,
Jim

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,480Questions: 1Answers: 10,467 Site admin
    Answer ✓

    Hi Jim,

    There is an example of using the insert() method available here.

    Am I better off using the content of $value or $row as a basis of the new row?

    I would say the $row parameter. That is what is in the database, which could possibly be different from what was submitted if you use formatters or database generated data (e.g. an updated time stamp).

    Allan

  • obrienjobrienj Posts: 93Questions: 38Answers: 0

    Allan,

    Thanks for the answer, it verified that $row is after validation and formatting..

    One follow-up, can I use $row directly as input to the "insert" or should I create a working array similar to the example and the modify the columns in it?

    Jim

  • allanallan Posts: 63,480Questions: 1Answers: 10,467 Site admin
    Answer ✓

    Hi Jim,

    Yes, you could use $row for the insert if the columns in the tables match. Personally I like being more explicit in the code than that - but it does lead to the odd bug if I change something and forget to update the object definition...

    Allan

This discussion has been closed.