I?m started to work with SC!
I?d like to have a question-summary, and a question-sheet for all Clients.
First: I manage the questions in the summary (in a multi row form) . if I create a new one, it should appear to all question-sheets per client! This functionality can be called via events or via a button and AJAX
e.g. Table cpm_risc_que
Column Typ
queid int(11)
cusart int(11)
question text NULL
rating int(11)
mutdate timestamp
e.g. Table cpm_risc_client
Column Typ
queid int(11)
nkunde double
queid int(11)
question text NULL
rating int(11) NULL
indrating int(11) NULL
yes_no tinyint(4) NULL
mutdate timestamp NULL
cusart int(11)
question text NULL
rating int(11)
mutdate timestamp
e.g. SQL in Event onAfterInsert:
/**
- Insert a record on another table
*/
// Insert record
$insert_sql = ‘INSERT INTO cpm_risc_client ( NKUNDE, queid, question, rating, mutdate )
SELECT cpm_cus.NKUNDE, cpm_risc_que.queid, cpm_risc_que.question, cpm_risc_que.rating, cpm_risc_que.mutdate
FROM cpm_risc_que INNER JOIN cpm_cus ON cpm_risc_que.cusart = cpm_cus.cusart’;
sc_exec_sql($insert_sql);
Result: all questions per client are inserted, (table empty)!
It works! But only with all rows from cpm_risc_que and table cpm_risc_client has to be empty!!
How can I get the current queid into the SQL??
$insert_sql = 'INSERT INTO cpm_risc_client ( NKUNDE, queid, question, rating, mutdate )
SELECT cpm_cus.NKUNDE, cpm_risc_que.queid, cpm_risc_que.question, cpm_risc_que.rating, cpm_risc_que.mutdate
FROM cpm_risc_que INNER JOIN cpm_cus ON cpm_risc_que.cusart = cpm_cus.cusart
Where cpm_risc_que.queid = {queid}?;
It is not working!!!