freddie
|
Posted: 03/02/2004, 8:25 AM |
|
I want to take three fields and set the contents of a forth field to these fields on an insert or update of a mysql record.
i.e. field1 = "123456" field2 = "987" field3 = "001"
resulting field4 shoud be = "123456-987-001"
How and where do I code this assignment?
Thanks
|
|
|
aradi
Posts: 66
|
Posted: 03/02/2004, 10:52 AM |
|
The following SQL can do it using MySql:
UPDATE Dbtable SET field1 = '123456',field2 = '987',field3 = '001',field4 = CONCAT_WS( "-", field1, field2, field3 );
or if the values of field1,field3,field3 already set then this will update field4:
UPDATE DBtable SET field4 = CONCAT_WS( "-", field1, field2, field3 );
|
|
|
freddie
|
Posted: 03/02/2004, 4:14 PM |
|
okay but where in CCS do I put this code????
And what about doing it with php?
|
|
|
RonB
|
Posted: 03/08/2004, 11:08 AM |
|
On Tue, 02 Mar 2004 08:25:43 -0800, freddie wrote:
> I want to take three fields and set the contents of a forth field to these fields on an insert or update of a mysql record.
>
> i.e. field1 = "123456" field2 = "987" field3 = "001"
>
> resulting field4 shoud be = "123456-987-001"
>
> How and where do I code this assignment?
>
> Thanks
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
In before show row:
$gridname->field4->setvalue($gridname->field1->GetValue() ."-"
..$gridname->field2->GetValue() ."-" . $gridname->field3->GetValue() );
RonB
|
|
|
Si Cranmer
|
Posted: 03/09/2004, 12:10 AM |
|
The extra DB updates need to be fired in
AfterUpdate & AfterInsert events
OR
If you make field4 a DB field then CCS will automaticaly updated/insert it to the DB so you can just do
$gridname->field4->setvalue($gridname->field1->GetValue() ."-"
..$gridname->field2->GetValue() ."-" . $gridname->field3->GetValue() );
in BeforeUpdate & BeforeInsert events.
HTH
Si.
|
|
|
|