Home » RADICORE » How To » Insert Multiple, Delete Multiple and parent keys
Insert Multiple, Delete Multiple and parent keys [message #1217] |
Sun, 13 January 2008 05:31  |
|
I am trying to write a code that would do Inserting or Deleting multiple records which will come from another table. I seem to be lost in setting parent table information in the $fieldarray before calling the InsertMutliple or DeleteMultiple.
Scenario ::
(in Relation to CLASSROOM-sample. Extending Student-Lesson to have records for all students and not only those without classids.)
When a new class-lesson gets created, I try to read all (getData) Students with the given classid, and want to insert it in Student-lesson with the lessonid from class-lesson. How do I add the lessonid in the $fieldarray returned by getData before doing the InsertMultiple or DeleteMultiple?
Thanks in advance.
|
|
|
|
Re: Insert Multiple, Delete Multiple and parent keys [message #1220 is a reply to message #1219] |
Mon, 14 January 2008 01:13   |
|
Thanks for directing my inquiry.
I see that UPDATE 5 seem to be the code that should handle the task. Please help me verify my understanding. My naive and probably obious question would be, should I call UPDATE 5 from the _cm_??? of Student or Class_lesson or both? Thus, if a student gets into a class (change of classid), then the UPDATE 5 task gets initiated and new records are added (to be done in student.class.inc). Likewise, if a class gets new lessons, the corresponding Update 5 task is also initiated.
|
|
|
Re: Insert Multiple, Delete Multiple and parent keys [message #1221 is a reply to message #1220] |
Mon, 14 January 2008 05:12   |
AJM
Messages: 2382 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
No, you do not call an UPDATE5 task from a '_cm_???' method, you have an UPDATE5 task which accesses a class which has code in a '_cm_???' method.
The whole purpose of the collection of '_cm_???' methods is that by default any task will perform a single operation on a single database table, but within the processing flow a '_cm_???' method may be called to perform some additional processing. By default all '_cm_???' methods (as defined in the superclass) are empty, which means that no additional processing will be performed.
This default behaviour can be changed at any time by putting whatever code you want inside the relevant '_cm_???' method inside your database table class, which means that at runtime the non-empty method will be called in preference to the empty method.
For example, if you wish to perform some additional processing after a STUDENT record is inserted, you put some code in the '_cm_post_insertRecord()' method of the STUDENT class. This code may instantiate objects on any table class, and may call whatever methods you like on the objects. This will enable you to read/write/update/delete any number of records from any number of tables. An example of this is shown in http://www.tonymarston.net/php-mysql/functions-and-variables .html#notes._cm_post_insertrecord.
|
|
|
Re: Insert Multiple, Delete Multiple and parent keys [message #1257 is a reply to message #1217] |
Thu, 21 February 2008 00:33   |
|
Thanks Tony. The documentation was most helpful. Finally we found time to continue to work again.
I would like to ask if numrows is also used in getData_raw. After getData_raw and i would like to process the array, will numrows contain the number of rows returned? Unfortunately the documentation was silent about this while getData_serial makes use of numrows.
|
|
|
|
Goto Forum:
Current Time: Thu Jun 19 21:32:43 EDT 2025
Total time taken to generate the page: 0.01388 seconds
|